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

时间:2019-03-07 08:08:55

标签: php smtp phpmailer

这是我的代码,相同的代码可以正常使用gmail和yahoo,但是Outlook或hotmail遇到此问题

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";
}

得到以下错误。

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]

0 个答案:

没有答案