PHPMailer身份验证失败
问题描述:
当我尝试在Windows Server 2012上使用PHPMailer在工作中使用SMTP发送报告电子邮件时,我收到身份验证失败错误。PHPMailer身份验证失败
我在域上使用服务器管理员帐户。
我非常确定密码的修正。
校验代码如下:
require '../PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';
$mail->Host = 'mail.example.com';
$mail->Port = 25;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = "[email protected]";
$mail->Password = "yourpassword";
$mail->setFrom('[email protected]', 'First Last');
$mail->addAddress('[email protected]', 'John Doe');
$mail->Subject = 'PHPMailer SMTP options test';
$mail->msgHTML($html_message);
我得到的以下响应:
SERVER -> CLIENT: 220 exchangeserverhost.com Microsoft ESMTP MAIL Service ready at Tue, 3 Nov 2015 22:19:26 +0300
CLIENT -> SERVER: EHLO exchangeserverhost.com
SERVER -> CLIENT: 250-exchangeserverhost.com Hello
CLIENT -> SERVER: STARTTLS
SERVER -> CLIENT: 220 2.0.0 SMTP server ready
CLIENT -> SERVER: EHLO exchangeserverhost.com
SERVER -> CLIENT: 250-exchangeserverhost.com Hello
CLIENT -> SERVER: AUTH LOGIN
SERVER -> CLIENT: 334
CLIENT -> SERVER:
SERVER -> CLIENT: 334
CLIENT -> SERVER: ==
SERVER -> CLIENT: 535 5.7.3 Authentication unsuccessful
SMTP ERROR: Password command failed: 535 5.7.3 Authentication unsuccessful
SMTP Error: Could not authenticate.
CLIENT -> SERVER: QUIT
SERVER -> CLIENT: 221 2.0.0 Service closing transmission channel
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
答
问题通过改变$ MAIL-> SMTPAUTH =真解决;假。
$ mail-> SMTPAuth = False;
得到正确的用户名和/或密码?我的意思是,这似乎是第一件要检查的事情。 – Twisty
我建议重新审视$ mail-> SMTPSecure ='tls'的配置;我想先尝试没有安全参数,看看它是如何工作的。通常安全的smtp会导致问题,如果不正确配置在主机。 – MansoorShiraz
如果STARTTLS不起作用,随后的EHLO也会失败,但事实并非如此,所以看起来您的加密工作正常。这看起来像一个简单的错误的id/pass问题。顺便说一句,那些认证字符串包含base64编码的纯文本ID和密码,所以如果我是你,我会编辑它。 – Synchro