我希望有人可以帮助我解决我在尝试解决问题时遇到的问题。我的网站上有一些代码,可以每天向我发送一封电子邮件。它最后一次运行是 12/1/17。唯一不起作用的部分是发送电子邮件的代码,PHP 日志中没有报告任何内容,但我从未收到电子邮件。我使用 gmail smtp,多年来一切正常。我打开了调试,结果让我卡住了。这是我所看到的:
DEBUG: Recv: 220 smtp.gmail.com ESMTP f67sm17798350pff.173 - gsmtp
DEBUG: Send: EHLO localhost
DEBUG: Recv: 250-smtp.gmail.com at your service, [xxx.xxx.xxx.xxx]
DEBUG: Recv: 250-SIZE 35882577
DEBUG: Recv: 250-8BITMIME
DEBUG: Recv: 250-STARTTLS
DEBUG: Recv: 250-ENHANCEDSTATUSCODES
DEBUG: Recv: 250-PIPELINING
DEBUG: Recv: 250-CHUNKING
DEBUG: Recv: 250 SMTPUTF8
DEBUG: Send: STARTTLS
DEBUG: Recv: 220 2.0.0 Ready to start TLS
DEBUG: Send: RSET
DEBUG: Recv: MIA+!&w����]];�ʻ��.~���]�v��J�MJk��+��s�������z��?|?�qI�s'Y>H���LO����~����O�J��ˆ�F�0��UM�߇�"Z�6ד�FL��J� ����vx�g�����L�����}���F���~����Чg���ek�7�4� z^�"��<��dP[p�`W~����^=bG���=�U�K�1+1؆�����;p"W�WE�3���P���F��Ԛ/D�TD܃�ʡ����â�d"�3!��ّ 3���U�,&r�X�@���.�@,��z��M�
DEBUG: Send: QUIT
似乎有些东西正在扰乱生成的调试信息?我在不同的浏览器和命令提示符下得到相同的结果。我不知道为什么(我怀疑它可能与 TLS 有关),我不确定如何阅读结果以查看是否存在错误。
预先感谢您的任何帮助。这将不胜感激。
这是发送电子邮件的代码,除了添加调试选项外没有任何变化。
再次感谢
function send_email ($email, $subject, $body, $from)
{
//Send an email to the user with thier password information
//Pear Mail information for mime
require_once "Mail.php";
require_once "Mail\mime.php";
//Send to and subject headers
$from = $from;
$to = $email;
//Pear mail information to send message
$mime = new Mail_mime();
$mime->setHTMLbody($body);
$body = $mime->get();
$headers = array(
'From' => $from,
'To' => $to,
'Subject' => $subject);
$headers = $mime->headers($headers);
$smtp = Mail::factory('smtp', array(
'host' => EMAIL_HOST,
'auth' => true,
'username' => EMAIL_USERNAME,
'password' => EMAIL_PASSWORD,
'port' => EMAIL_PORT,
'debug' => true));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
$result = (''.$mail->getMessage().'');
} else {
$result = ("Message successfully sent! \r\n. Email was sent to $to \r\n");
}
return ($result);
}