【发布时间】:2013-08-02 01:40:45
【问题描述】:
我知道已经有人问过这个问题,但没有答案可以帮助我。
这是我的代码,希望你能找到错误。
<?php
require("phpMailer/class.phpmailer.php");
require("phpMailer/class.smtp.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Host = 'smtp.example.com';
$mail->Port = 587;
$mail->Username = "mailer@example.com"; // SMTP username
$mail->Password = "validpassword"; // SMTP password
$mail->From = "mailer@example.com";
$mail->FromName = "Mailer";
$mail->AddAddress("my.email@gmail.com");
$mail->AddReplyTo("mailer@example.com", "Mailer");
$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = "Here is the subject";
$mail->Body = "This is the HTML message body <b>in bold!</b>";
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>
PS : 有趣的事实是我的邮件不会通过 mailer() 进入垃圾邮件...但我必须使用 Phpmailer。
【问题讨论】:
-
当您使用
mail()与PHPMailer时,您在标题中看到了什么不同? -
如果它位于垃圾邮件文件夹中,您的电子邮件中可能会有一个额外的标题来解释垃圾邮件分数和阈值。 (spamfighter 和 spamassassin 做这个 afaik)
-
发送到垃圾邮件的地址是否完全相同?
-
@Bamar
$headers .='Content-Type: text/plain; charset="iso-8859-1"'."\n"; $headers .= 'Content-Transfer-Encoding: 8bit"'."\n"; $headers .= "Date:" . $entetedate . "\n";@Anigel 我不明白你的问题对不起,也许我的英语没有我想象的那么好。 -
您说它会通过 phpmailer 进入垃圾邮件,但如果您使用邮件则不会。您是否使用这两种方法向同一个电子邮件地址发送相同的电子邮件?
标签: php email smtp phpmailer spam