简体   繁体   English

通过PHPMailer发送SMTP电子邮件突然开始失败

[英]Sending SMTP email via PHPMailer started failing suddenly

I have been using PHPMailer to send SMTP email on behalf of my office365 account, and it was working for about a week. 我一直在使用PHPMailer代表我的office365帐户发送SMTP电子邮件,并且已经工作了大约一周。 Then it suddenly quit working and I don't know what changed. 然后它突然停止工作,我不知道发生了什么变化。

When I enable high debug logging in PHPMailer I see this: 当我在PHPMailer中启用高调试日志记录时,我看到以下内容:

SMTP -> FROM SERVER:220 CY4PR15CA0011.outlook.office365.com Microsoft ESMTP MAIL Service ready at Thu, 10 Jan 2019 13:30:20 +0000 SMTP -> FROM SERVER: 250-CY4PR15CA0011.outlook.office365.com Hello [198.154.243.158] 250-SIZE 157286400 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-STARTTLS 250-8BITMIME 250-BINARYMIME 250-CHUNKING 250 SMTPUTF8 SMTP -> ERROR: AUTH not accepted from server: 504 5.7.4 Unrecognized authentication type [CY4PR15CA0011.namprd15.prod.outlook.com] SMTP -> FROM SERVER:250 2.0.0 Resetting SMTP->来自服务器:220 CY4PR15CA0011.outlook.office365.com Microsoft ESMTP邮件服务已于2019年1月10日星期四准备就绪13:30:20 +0000 SMTP->来自服务器:250-CY4PR15CA0011.outlook.office365.com你好[198.154 .243.158] 250-SIZE 157286400 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-STARTTLS 250-8BITMIME 250-BINARYMIME 250-CHUNKING 250 SMTPUTF8 SMTP->错误:服务器未接受AUTH:504 5.7.4无法识别的身份验证类型[CY4PR15CA0011 [.namprd15.prod.outlook.com] SMTP->从服务器:250 2.0.0重置

This piece seems to be the most relevant: 这似乎是最相关的:

AUTH not accepted from server: 504 5.7.4 Unrecognized authentication type 服务器未接受AUTH:504 5.7.4无法识别的身份验证类型

Here are my literal SMTP settings as being handed to PHPMailer: 这是我传递给PHPMailer的原本SMTP设置:

smtpAuth: true
smtpSecure: STARTTLS
smtpHost: smtp.office365.com
smtpPort: 587
smtpUsername: [hidden]
smtpPassword: [hidden]
emailTo: [hidden]

And the actual PHP code: 以及实际的PHP代码:

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = $smtpAuth;
$mail->SMTPSecure = $smtpSecure;
$mail->Host = $smtpHost;
$mail->Port = $smtpPort;
$mail->Username = $smtpUsername;
$mail->Password = $smtpPassword;
$mail->SetFrom($smtpSenderDisplay);
$mail->IsHTML(true);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($emailTo);

As as sanity check, I set up an SMTP account with these same settings in Windows Live Mail - and everything works. 作为健全性检查,我在Windows Live Mail设置了具有相同设置的SMTP帐户-一切正常。 No errors. 没有错误。 Outgoing email lands in the inbox of a different email account I have. 外发电子邮件将落在我拥有的其他电子邮件帐户的收件箱中。

So Windows Live Mail is doing something a little differently from what my PHP script is doing AND remember my PHP script was working fine up until a few days ago. 因此,Windows Live Mail所做的事情与我的PHP脚本所做的有所不同,请记住,直到几天前我的PHP脚本都可以正常工作。

Any ideas what I need to change? 有什么需要改变的想法吗?

Microsoft changed their SMTP encryption requirement from STARTTLS to TLS. Microsoft将SMTP加密要求从STARTTLS更改为TLS。 That solved it. 那解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM