PHPMailer 验证失败

问题描述 投票:0回答:3

当我在工作中尝试在 Windows Server 2012 上使用 PHPMailer 使用 SMTP 发送报告电子邮件时,出现身份验证失败错误。

我在域上使用服务器管理员帐户。

我非常确定密码正确无误。

检查下面的代码:

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
php phpmailer
3个回答
1
投票

$mail->SMTPAuth = true;
更改为
False
即可解决问题。

$mail->SMTPAuth = False;

0
投票

如果您使用的是 GoDaddy 的 Office 365 并且启用了 2FA,请按照这些步骤禁用 2FA。这解决了我的问题,即使

SMTPAuth
true
,它也能工作。


0
投票

有类似的问题,搜索谷歌并将其发送到这里:)我找到了解决方案:按照此处的以下步骤操作,但不要执行天蓝色的操作:https://answers.microsoft.com/en-us/msoffice/forum/all /smtp-不工作/bbf1176a-5788-446d-86e7-79bfc371d12c

在完成这些第一步之后,您可以这样做: https://learn.microsoft.com/en-us/entra/fundamentals/security-defaults

© www.soinside.com 2019 - 2024. All rights reserved.