$to = 'abc@xyz.com';
$subject = 'Feedback';
$finalmessage = "";
$from = 'def@ghi.com';
$finalmessage = $name . $address . $phnum . $email . $feedback;
$finalmessage = wordwrap($finalmessage, 70);
$mail=mail($to,$subject,$finalmessage,"From: $from\n");
if($mail){
echo "Thank you for using our mail form";
}else{
echo "Mail sending failed.";
}
这是代码。最后显示"感谢您使用我们的邮件表格",但我没有收到任何邮件。任何想法都出错了?
答案 0 :(得分:1)
如果(isset($ _ POST ['提交'])){
$to="email";
// this is your Email address
$from = $_POST['Email_Address']; // this is the sender's Email address
$first_name = $_POST['Full_Name'];
$tel_num=$_POST['Telephone_Number'];
$msg=$_POST['Your_Message'];
$subject = "Full Name : ".$first_name;
$headers = "From: ".$first_name." <".$from.">\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$message="Full Name : ".$first_name."<br><br>Telephone Number : ".$tel_num."<br><br>Message : ".$msg;
$bericht = nl2br($message);
mail($to,$subject,$message,$headers);
}
答案 1 :(得分:0)
您需要在php.ini
文件中配置本地服务器的SMTP设置,如下所示:
[mail function]
; For Win32 only.
SMTP = localhost // your smtp server
smtp_port = 25
或者您应该尝试Swift Mailer或PHP Mailer
答案 2 :(得分:0)
使用php mailer()函数
您可以使用PHPmailer: http://phpmailer.codeworxtech.com/
现在 使用以下代码 -
<?php
require("class.phpmailer.php"); // give proper path of folder if needed
$mail = new PHPMailer();
session_start();
ob_start();
php?>
<your mail body goes here>
<?php
$body=ob_get_contents();
ob_end_clean ();
$to = 'abc@xyz.com';
$subject = 'Feedback';
$finalmessage = "";
$from = 'def@ghi.com';
$finalmessage = $name . $address . $phnum . $email . $feedback;
$finalmessage = wordwrap($finalmessage, 70);
$mail->Host = "mail.yourdomain.com"; // SMTP server
$mail->IsHTML(true);
$mail=mail($to,$subject,$finalmessage,"From: $from\n");
if($mail){
echo "Thank you for using our mail form";
}else{
echo "Mail sending failed.";
}
答案 3 :(得分:0)
尝试使用假的sendmail在Windows环境中发送电子邮件。
答案 4 :(得分:0)
您需要在php.ini中配置邮件SMTP 这很简单,你的ISP是什么?例如,在comcast中,只需在Google中搜索“comcast smtp地址和端口”
记下SMTP地址和端口,然后转到php.ini 搜索此配置:
[mail function]
; For Win32 only.
SMTP = localhost // your smtp server
smtp_port = 25
使用SMTP和smtp_port更改地址。然后你应该能够在localhost中发送电子邮件