首页 > 解决方案 > Office365 smtp 并不总是与 php 邮件程序一起使用

问题描述

我正在尝试将 office365 smtp 与 phpmailer 一起使用,它会进行身份验证并有时会提供,但有时会。不在收件箱或垃圾邮件中。它适用于其他 smtp 服务器。这是我的代码:

$mail = new PHPMailer(true);

//Enable SMTP debugging.
$mail->SMTPDebug = 3;  
$mail->CharSet =  "utf-8";
//Set PHPMailer to use SMTP.
$mail->isSMTP();            
//Set SMTP host name                          
$mail->Host = $host;
//Set this to true if SMTP host requires authentication to send email
$mail->SMTPAuth = true;
$mail->AuthType = 'LOGIN';
//Provide username and password     
$mail->Username = $user;                 
$mail->Password = $pass;                           
//If SMTP requires TLS encryption then set it
$mail->SMTPSecure = "STARTTLS";                           
//Set TCP port to connect to
$mail->Port = $port;                                   

$mail->From = $from_email;
$mail->FromName = $from_name;

foreach($recipients as $recipients){
$mail->AddBcc($recipients);
}

$mail->isHTML(true);

$mail->Subject = $subject;
$mail->msgHTML($message);

标签: phpsmtpoffice365phpmailer

解决方案


推荐阅读