php - 带有 SMTP 和 Outlook 的 PHPMailer
问题描述
我正在尝试将 PHPMailer 与 SMTP 一起使用。由于“中继访问被拒绝 ATTR36 ...”错误,它失败。它建议了一个网址以获取更多详细信息。实际上信息量很大,通常我会在这里停下来解决明显的中继问题,但是我有第二个脚本可以与 SMTP 一起使用到同一主机。它还会自动检测“tls”。
//Script 1 Fails
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Host = '************.mail.protection.outlook.com';
//$mail->SMTPSecure='tls'; //I've tried setting this but still the same results.
$mail->Port = 25;
$mail->SetFrom('FromEmail@************.com');
$mail->addAddress('ToEmail@************.com');
$mail->Subject = 'TEST SUBJECT';
$mail->msgHTML($content);
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
因此,为了检查服务器是否接受中继,我使用来自 http://caspian.dotconf.net/menu/Software/SendEmail/的 SendEmail进行测试。
//脚本 2 工作
sendEmail.pl -f FromEmail@************.com -t ToEmail@************.com -u 'TEST SUBJECT' -s '************.mail.protection.outlook.com' -m $content
这第一次奏效。
我很确定这与 tls 和我有/没有设置的选项有关。有人有什么想法吗?我会很感激任何建议。
解决方案
我发现了问题。我不小心在我的 PHPMailer 测试脚本的“发件人”电子邮件中转置了 2 个字符。不正确的拼写导致“中继访问被拒绝”错误。我的错。谢谢大家的建议。
推荐阅读
- python - Do we apply fourier/wavelet transform to entire time series or only the training set for forecasting?
- nginx - 如何在 K8S 中获取 NGINX VirtualServer 和 VirtualServerRoute 的列表?
- sql - 如何使用 Rails 和 SQL 动态处理嵌套的 WHERE AND/OR 查询
- mysql - MySQL:在单个查询中,如何检查是否存在特定的关联组?
- db2 - DB2 生成 GUID/UUID
- javascript - 无法完成与服务器的协商 - Angular + SignalR
- python - 如何从一行中删除一个空格
- gulp - 返回流但仍然出现错误“您忘记了异步完成吗?” 吞咽 4
- react-native - Android 资源链接失败 - AAPT:错误:找不到资源 android:attr/dialogCornerRadius
- php - 在php中生成带有标题和详细信息的txt