SMTP服务器错误:发送Outlook邮件时使用PHPMailer

Here is my code, The same code is working gmail and yahoo but outlook or hotmail getting this issue

include("phpmailer/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->CharSet = 'UTF-8';
$mail->Host = "smtp.live.com";//tried smtp-mail.outlook.com,smtp.office365.com
$mail->SMTPAuth= true;
$mail->Port = 587;
$mail->Username= $account;
$mail->Password= $password;
$mail->SMTPSecure = 'tls';
$mail->From = $from;
$mail->FromName= $from_name;
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $msg;
$mail->addAddress($to);
if(!$mail->send()){
 echo "Mailer Error: " . $mail->ErrorInfo;
}else{
 echo "E-Mail has been sent";
}

Getting below Error.

SMTP -> FROM SERVER:220 DM5PR0101CA0036.outlook.office365.com Microsoft ESMTP MAIL Service ready at Thu, 7 Mar 2019 07:59:09 +0000 
SMTP -> FROM SERVER: 250-DM5PR0101CA0036.outlook.office365.com Hello [146.148.75.233] 250-SIZE 157286400 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-STARTTLS 250-8BITMIME 250-BINARYMIME 250-CHUNKING 250 SMTPUTF8 
SMTP -> FROM SERVER:220 2.0.0 SMTP server ready 
SMTP -> FROM SERVER: 250-DM5PR0101CA0036.outlook.office365.com Hello [146.148.75.233] 250-SIZE 157286400 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-AUTH LOGIN XOAUTH2 250-8BITMIME 250-BINARYMIME 250-CHUNKING 250 SMTPUTF8 
SMTP -> ERROR: Password not accepted from server: 
SMTP -> FROM SERVER:535 5.7.3 Authentication unsuccessful [DM5PR0101CA0036.prod.exchangelabs.com] 
SMTP -> ERROR: RSET failed: 535 5.7.3 Authentication unsuccessful [DM5PR0101CA0036.prod.exchangelabs.com] 
SMTP Error: Could not authenticate. Mailer Error: SMTP Error: Could not authenticate.
SMTP server error: 5.7.3 Authentication unsuccessful [DM5PR0101CA0036.prod.exchangelabs.com]
doufei16736
doufei16736 服务器不接受密码似乎很清楚;正如Praveen建议的那样,auth被禁用,或者您的ID或密码错误。调试日志不完整-您可以使用SMTPDebug=2发布所有调试日志。
一年多之前 回复
dongtui4038
dongtui4038 您是否为Outlook启用SMTP身份验证?
一年多之前 回复
doushan3511
doushan3511 代码对我来说很好,我会怀疑服务器端有什么问题(尤其是Office365),因为它有很多阻止你处理所有事情的机制。
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问