【问题标题】:How to connect to Office 365 with PHPMailer?如何使用 PHPMailer 连接到 Office 365?
【发布时间】:2017-04-07 05:14:41
【问题描述】:

我的 PHPMailer 有问题,我想连接到使用我的网站 IP 配置的 Office 365 服务器,这里有一个连接器,因此我可以连接到 Office 365 SMTP 服务器,无需身份验证即可连接,因为我的 IP 地址已列入白名单。

问题是我无法对服务器进行身份验证。

PHPMailer 输出:

2016-11-23 09:06:50 CLIENT -> SERVER: EHLO www.thuis*******.nl 2016-11-23 09:06:50  SMTP Error: Could not authenticate. 2016-11-23 09:06:50 CLIENT -> SERVER: QUIT 2016-11-23 09:06:50  SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

PHP 文件:

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = '';
$mail->SMTPAutoTLS = false;
$mail->Host = "thuis*******-nl.mail.protection.outlook.com";
$mail->Port = 25;
$mail->SetFrom('john@thuis*******.nl', 'John');
$mail->AddReplyTo("noreply@thuis*******.nl");
$mail->Subject = "This is the subject";
$mail->MsgHTML('Message body');
$address = "john@doe.nl";
$mail->AddAddress($address);
if(!$mail->Send()) {
   echo "Mailer Error: " . $mail->ErrorInfo;
 } else {
   echo "Message sent!";
}

【问题讨论】:

  • 您的代码基于一个过时的示例,因此请确保您使用的是最新版本。如果您阅读错误消息指向的文档,也会有所帮助。
  • @Synchro 谢谢,我找到了解决办法,你可以在下面阅读。

标签: office365 phpmailer office365connectors


【解决方案1】:

SMTPAuth 设置为false

$mail->SMTPAuth = false;

原因:我的服务器没有配置任何电子邮件帐户。

服务器 IP 地址被列入白名单,可以从任何带有@thuis*******.nl 的邮件地址发送邮件。

【讨论】:

    猜你喜欢
    • 2018-03-14
    • 1970-01-01
    • 1970-01-01
    • 2017-09-14
    • 2012-04-27
    • 2018-06-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多