我有一个使用phpmailer的PHP脚本:
require("PHPMailer/PHPMailerAutoload.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = false;
$mail->IsSendmail();
$mail->Host = "localhost";
$mail->Port = 587;
$mail->SetFrom($from, 'BuzzZap');
$mail->Subject = $subject;
$mail->MsgHTML($body);
$mail->AddAddress($to, $to);
if ($mail->Send()) {
echo "Message sent!";
return true;
} else {
echo "Mailer Error: " . $mail->ErrorInfo;
return false;
}
(有些变量在别处定义,但是明确定义)
所以,我在实时服务器上运行端口25和587(当我运行netstat -tulnp
时)时发送sendmail。脚本确实说"成功发送"并且不会产生错误,警告等.Mail.log显示:
8 17:33:23 casparwylie sendmail[2601]: u18HXNFd002601: Authentication-Warning: casparwylie: www-data set sender to billing@buzzzap.com using -f
Feb 8 17:33:23 casparwylie sendmail[2601]: u18HXNFd002601: from=billing@buzzzap.com, size=2178, class=0, nrcpts=1, msgid=<5e0e6f2a4e12ddb8524541a13b2a76a1@buzzzap.com>, relay=www-data@l$
Feb 8 17:33:23 casparwylie sm-mta[2602]: u18HXNK9002602: from=<billing@buzzzap.com>, size=2393, class=0, nrcpts=1, msgid=<5e0e6f2a4e12ddb8524541a13b2a76a1@buzzzap.com>, proto=ESMTP, dae$
Feb 8 17:33:23 casparwylie sendmail[2601]: u18HXNFd002601: to="casparwylie@googlemail.com" <casparwylie@googlemail.com>, ctladdr=billing@buzzzap.com (33/33), delay=00:00:00, xdelay=00:0$
Feb 8 17:33:23 casparwylie sm-mta[2604]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1/SSLv3, verify=FAIL, cipher=ECDHE-RSA-AES128-GCM-SHA256, bits=128/128
Feb 8 17:33:24 casparwylie sm-mta[2604]: u18HXNK9002602: to=<casparwylie@googlemail.com>, delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=122393, relay=gmail-smtp-in.l.google.com. [7$
Feb 8 17:33:26 casparwylie sendmail[2606]: u18HXQoo002606: Authentication-Warning: casparwylie: www-data set sender to billing@buzzzap.com using -f
Feb 8 17:33:26 casparwylie sendmail[2606]: u18HXQoo002606: from=billing@buzzzap.com, size=2178, class=0, nrcpts=1, msgid=<2a08b37d9e3ea189c1e61648a3e2e5f8@buzzzap.com>, relay=www-data@l$
Feb 8 17:33:26 casparwylie sm-mta[2607]: u18HXQXe002607: from=<billing@buzzzap.com>, size=2393, class=0, nrcpts=1, msgid=<2a08b37d9e3ea189c1e61648a3e2e5f8@buzzzap.com>, proto=ESMTP, dae$
Feb 8 17:33:26 casparwylie sendmail[2606]: u18HXQoo002606: to="casparwylie@googlemail.com" <casparwylie@googlemail.com>, ctladdr=billing@buzzzap.com (33/33), delay=00:00:00, xdelay=00:0$
Feb 8 17:33:26 casparwylie sm-mta[2609]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1/SSLv3, verify=FAIL, cipher=ECDHE-RSA-AES128-GCM-SHA256, bits=128/128
Feb 8 17:33:26 casparwylie sm-mta[2609]: u18HXQXe002607: to=<casparwylie@googlemail.com>, delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=122393, relay=gmail-smtp-in.l.google.com. [7$
我尝试发送的每封电子邮件。
但是,我在检查casparwylie@gmail.com时根本没有收到电子邮件。
感谢任何帮助 - 我明显误解了一些事情!
答案 0 :(得分:1)
当您通过位于localhost的SMTP
发送电子邮件时,您不必指定SMTP
相关设置。所以尝试删除这些行:
$mail->IsSMTP();
$mail->SMTPAuth = false;
$mail->IsSendmail();
$mail->Host = "localhost";
$mail->Port = 587;
注意:请不要忘记查看您的SPAM
文件夹