当来自 CLI (cron) 的脚本 运行 时,PHPMailer 被 "Host impersonating" 拒绝
PHPMailer being rejected with "Host impersonating" when script run from CLI (cron)
我通过 bluehost.com 托管了一个站点,该站点具有我围绕 PHPMailer 构建的电子邮件功能。 运行 没问题,但 bluehost 似乎在过去 24 小时内更改了一些安全设置。调试通过它,我不知道如何解决这个问题。
看来 bluehost 已将其端配置为现在验证连接到 SMTP 服务器的主机。如果我在浏览网站时触发电子邮件,电子邮件仍然可以正常发送:
SERVER -> CLIENT: 220-box304.bluehost.com ESMTP Exim 4.86_2 #1 Wed, 20 Jul 2016 10:16:19 -0600 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
CLIENT -> SERVER: EHLO www.fydentry.com
SERVER -> CLIENT: 250-box304.bluehost.com Hello www.fydentry.com [69.89.31.104]250-SIZE 52428800250-8BITMIME250-AUTH PLAIN LOGIN250 HELP
CLIENT -> SERVER: AUTH LOGIN
...
SERVER -> CLIENT: 235 Authentication succeeded
有些(大多数)电子邮件不是以交互方式发送的,而是在数据库中排队,php 脚本通过 cron 作业在后台定期执行,以发送这些电子邮件。这曾经工作正常,但从昨天开始,脚本现在抛出错误:
SERVER -> CLIENT: 220-box304.bluehost.com ESMTP Exim 4.86_2 #1 Wed, 20 Jul 2016 10:30:08 -0600 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
CLIENT -> SERVER: EHLO box304.bluehost.com
SERVER -> CLIENT: 550 "REJECTED - Bad HELO - Host impersonating [box304.bluehost.com]"
SMTP ERROR: EHLO command failed: 550 "REJECTED - Bad HELO - Host impersonating [box304.bluehost.com]"
CLIENT -> SERVER: HELO box304.bluehost.com
SERVER -> CLIENT: 550 "REJECTED - Bad HELO - Host impersonating [box304.bluehost.com]"
SMTP ERROR: HELO command failed: 550 "REJECTED - Bad HELO - Host impersonating [box304.bluehost.com]"
CLIENT -> SERVER: QUIT
SERVER -> CLIENT: 221 box304.bluehost.com closing connection
SMTP connect() failed.
我可以看到交互式日志标识了源站点 www.fydentry.com,但是通过 cli (cron) 执行的 php 脚本只看到了框名称,并确定不是一个有效的来源。
是否有我可以添加到命令行的参数,以便脚本从站点地址看起来是 运行?或者我可以在 PHP 脚本中做些什么来模拟这个?或者这是 bluehost 方面的配置问题,我应该要求他们纠正?还是我完全错过了这里的某些东西,还有其他我应该做的事情?
目前我已经通过在 cron 作业中调用一个基本的包装器脚本解决了这个问题,该脚本又执行了这个:
file_get_contents("http://www.fydentry.com/my-mailer-script.php");
这似乎足以欺骗网站上脚本 运行 的一切。但这似乎不是一个好的长期解决方案。
我昨天遇到了同样的问题。我只能想象人们现在遇到的所有问题。
无论如何,既然您已经围绕 PHPMailer class 构建了它,请尝试在您的邮件对象上设置 "Helo" 属性。这对我有用。
来自文档(http://phpmailer.worxware.com/?pg=properties):
$Helo public Sets the SMTP HELO of the message (Default is $Hostname)
希望对您有所帮助!
这为我解决了:
$mail->Hostname = "yourhostname.com";
$mail->Helo = $mail->Hostname;
我通过 bluehost.com 托管了一个站点,该站点具有我围绕 PHPMailer 构建的电子邮件功能。 运行 没问题,但 bluehost 似乎在过去 24 小时内更改了一些安全设置。调试通过它,我不知道如何解决这个问题。
看来 bluehost 已将其端配置为现在验证连接到 SMTP 服务器的主机。如果我在浏览网站时触发电子邮件,电子邮件仍然可以正常发送:
SERVER -> CLIENT: 220-box304.bluehost.com ESMTP Exim 4.86_2 #1 Wed, 20 Jul 2016 10:16:19 -0600 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
CLIENT -> SERVER: EHLO www.fydentry.com
SERVER -> CLIENT: 250-box304.bluehost.com Hello www.fydentry.com [69.89.31.104]250-SIZE 52428800250-8BITMIME250-AUTH PLAIN LOGIN250 HELP
CLIENT -> SERVER: AUTH LOGIN
...
SERVER -> CLIENT: 235 Authentication succeeded
有些(大多数)电子邮件不是以交互方式发送的,而是在数据库中排队,php 脚本通过 cron 作业在后台定期执行,以发送这些电子邮件。这曾经工作正常,但从昨天开始,脚本现在抛出错误:
SERVER -> CLIENT: 220-box304.bluehost.com ESMTP Exim 4.86_2 #1 Wed, 20 Jul 2016 10:30:08 -0600 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
CLIENT -> SERVER: EHLO box304.bluehost.com
SERVER -> CLIENT: 550 "REJECTED - Bad HELO - Host impersonating [box304.bluehost.com]"
SMTP ERROR: EHLO command failed: 550 "REJECTED - Bad HELO - Host impersonating [box304.bluehost.com]"
CLIENT -> SERVER: HELO box304.bluehost.com
SERVER -> CLIENT: 550 "REJECTED - Bad HELO - Host impersonating [box304.bluehost.com]"
SMTP ERROR: HELO command failed: 550 "REJECTED - Bad HELO - Host impersonating [box304.bluehost.com]"
CLIENT -> SERVER: QUIT
SERVER -> CLIENT: 221 box304.bluehost.com closing connection
SMTP connect() failed.
我可以看到交互式日志标识了源站点 www.fydentry.com,但是通过 cli (cron) 执行的 php 脚本只看到了框名称,并确定不是一个有效的来源。
是否有我可以添加到命令行的参数,以便脚本从站点地址看起来是 运行?或者我可以在 PHP 脚本中做些什么来模拟这个?或者这是 bluehost 方面的配置问题,我应该要求他们纠正?还是我完全错过了这里的某些东西,还有其他我应该做的事情?
目前我已经通过在 cron 作业中调用一个基本的包装器脚本解决了这个问题,该脚本又执行了这个:
file_get_contents("http://www.fydentry.com/my-mailer-script.php");
这似乎足以欺骗网站上脚本 运行 的一切。但这似乎不是一个好的长期解决方案。
我昨天遇到了同样的问题。我只能想象人们现在遇到的所有问题。
无论如何,既然您已经围绕 PHPMailer class 构建了它,请尝试在您的邮件对象上设置 "Helo" 属性。这对我有用。
来自文档(http://phpmailer.worxware.com/?pg=properties):
$Helo public Sets the SMTP HELO of the message (Default is $Hostname)
希望对您有所帮助!
这为我解决了:
$mail->Hostname = "yourhostname.com";
$mail->Helo = $mail->Hostname;