首页 > 解决方案 > 带有 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 和我有/没有设置的选项有关。有人有什么想法吗?我会很感激任何建议。

标签: phpsmtpphpmailer

解决方案


我发现了问题。我不小心在我的 PHPMailer 测试脚本的“发件人”电子邮件中转置了 2 个字符。不正确的拼写导致“中继访问被拒绝”错误。我的错。谢谢大家的建议。


推荐阅读