0

我已经使用域名创建了一个 Office 365 管理员帐户。我还在图片中的安全信息显示中启用了我的帐户中的两步验证:

office365 身份验证配置

但是,每当我使用此帐户向我发送邮件时,都会出现这样的错误。

2021-02-10 05:33:32 Auth method requested: UNKNOWN
2021-02-10 05:33:32 Auth methods available on the server: LOGIN,XOAUTH2
2021-02-10 05:33:32 Auth method selected: LOGIN
2021-02-10 05:33:32 CLIENT -> SERVER: AUTH LOGIN
2021-02-10 05:33:32 SMTP -> get_lines(): $data is ""
2021-02-10 05:33:32 SMTP -> get_lines(): $str is  "334 VXNlcm5hbWU6
                                      "
2021-02-10 05:33:32 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2021-02-10 05:33:32 CLIENT -> SERVER: xxx
2021-02-10 05:33:32 SMTP -> get_lines(): $data is ""
2021-02-10 05:33:32 SMTP -> get_lines(): $str is  "334 UGFzc3dvcmQ6
                                      "
2021-02-10 05:33:32 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2021-02-10 05:33:32 CLIENT -> SERVER: xxx
2021-02-10 05:33:37 SMTP -> get_lines(): $data is ""
2021-02-10 05:33:37 SMTP -> get_lines(): $str is  "535 5.7.3 Authentication unsuccessful [PN0PR01CA0004.INDPRD01.PROD.OUTLOOK.COM]
                                      "
2021-02-10 05:33:37 SERVER -> CLIENT: 535 5.7.3 Authentication unsuccessful [PN0PR01CA0004.INDPRD01.PROD.OUTLOOK.COM]
2021-02-10 05:33:37 SMTP ERROR: Password command failed: 535 5.7.3 Authentication unsuccessful [PN0PR01CA0004.INDPRD01.PROD.OUTLOOK.COM]
2021-02-10 05:33:37 SMTP Error: Could not authenticate.
2021-02-10 05:33:37 CLIENT -> SERVER: QUIT
2021-02-10 05:33:38 SMTP -> get_lines(): $data is ""
2021-02-10 05:33:38 SMTP -> get_lines(): $str is  "221 2.0.0 Service closing transmission channel
                                      "
2021-02-10 05:33:38 SERVER -> CLIENT: 221 2.0.0 Service closing transmission channel
2021-02-10 05:33:38 Connection: closed
2021-02-10 05:33:38 SMTP Error: Could not authenticate.
<br />
<b>Fatal error</b>:  Uncaught phpmailerException: SMTP Error: Could not authenticate. in C:\xampp\htdocs\dede\PHPMailer\class.phpmailer.php:1714
Stack trace:
#0 C:\xampp\htdocs\dede\PHPMailer\class.phpmailer.php(1557): PHPMailer-&gt;smtpConnect(Array)
#1 C:\xampp\htdocs\dede\PHPMailer\class.phpmailer.php(1340): PHPMailer-&gt;smtpSend('Date: Wed, 10 F...', 'This is a multi...')
#2 C:\xampp\htdocs\dede\PHPMailer\class.phpmailer.php(1215): PHPMailer-&gt;postSend()
#3 C:\xampp\htdocs\dede\register.php(187): PHPMailer-&gt;send()
#4 {main}

如何使用两步验证发送 SMTP 邮件?我还创建了两个活动用户,例如 user1 和 user2。如果我想使用该用户发送 SMTP 邮件,我该怎么办?

4

1 回答 1

0

为了使用 SMTP 身份验证,Office 365 需要启用以下设置:

Host = "smtp.office365.com"
Port = 587
SMTPAuth = true;
SMTPSecure = "tls";
SMTPAutoTLS = true;

此外, 的值From必须与 的值匹配,Username否则 Microsoft 的 SMTP 服务器将拒绝它。

第二:检查该邮箱是否启用了 SMTP AUTH,请参阅https://docs.microsoft.com/en-us/exchange/clients-and-mobile-in-exchange-online/authenticated-client-smtp-submission

另外:如果您必须为此帐户使用 MFA,请确保使用应用程序密码:https ://docs.microsoft.com/en-us/azure/active-directory/user-help/multi-factor-authentication-最终用户应用程序密码

于 2021-02-18T05:37:40.177 回答