【发布时间】:2013-08-12 22:29:42
【问题描述】:
我正在开发一个网站,您可以在其中通过电子邮件询问我们的问题。每次我发送它,它总是进入垃圾邮件 这是我的代码:
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$phone = $_POST['phone'];
$city = $_POST['city'];
$QuestionComment = $_POST['comments'];
$hear = $_POST['about_us'];
$email_address = $_POST['email'];
// the first email is for thank you! email
date_default_timezone_set('Asia/Manila');
$mail = new PHPMailer();
$body = "Hi,<br /> <br />Thank you for contacting Magosaburo Philippines. <br />Please await for a confirmation email regarding your reservations and other concerns.";
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.magosaburo.com.ph"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "mail.magosaburo.com.ph"; // sets the SMTP server
$mail->Port = 25; // set the SMTP port for the GMAIL server
$mail->Username = "//dont mind it"; // SMTP account username
$mail->Password = "//dont mind it"; // SMTP account password
$address = $email_address;
$mail->AddAddress($address);
$mail->Subject = "Thank you from Magosaburo";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->SetFrom('send_mail@magosaburo.com.ph', 'Magosaburo');
$mail->AddReplyTo("send_mail@magosaburo.com.ph",'Magosaburo');
$mail->MsgHTML($body);
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message sent!";
}
我是 php 电子邮件发送的新手,我不知道它如何或为什么会进入垃圾邮件。谢谢!
【问题讨论】:
-
comment date_default_timezone_set('Asia/Manila');看看它是否有效
-
在我的 gmail 上它进入垃圾邮件,而在我的 yahoo 上进入收件箱。
-
Gmail 的垃圾邮件过滤器可能会阻止您的代码,因为它们没有找到您的电子邮件地址的 IP 和邮件服务器域;s IP 匹配,这又是我的猜测