php - 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);
解决方案
推荐阅读
- python - 优化 numpy 网格创建以实现高效插值
- python - 写入 excel 文件的 Python 程序仅写入最后一行
- c# - 如何在 Docker 中使用 Selenium 运行 dotnet core 应用程序
- java - spring boot - 将正确的响应映射到请求,用于多异步调用
- c# - 如何在 C# 控制台应用程序中实现垂直滚动条
- react-native - react-native unrecognized font family FontAwesome5Pro-Solid
- javascript - 错误:页面的字符编码必须在文档或传输协议中声明
- javascript - event.stopPropagation 不适用于伪元素?
- c# - ASP.NET Core 中的循环依赖
- php - 向/从二维数组添加/获取数据不起作用