Swiftmailer SMTP transport rejecting local IP address

会有一股神秘感。 提交于 2019-12-10 17:09:00

问题


I'm trying to send an email using the Swift_SmtpTransport but I'm getting the following error:

501 5.5.2 <[::1]>: Helo command rejected: invalid ip address

The SMTP server is a remote server and it works from my production server, but not from my development machine, which is running OS X.

It also doesn't bother to throw an exception, instead it required me to use a logger plugin to find out why it wasn't working.

What can I do to make it use a real IP address?


回答1:


I did some poking around in the code and found it.

When configuring the SMTP transport, you need to call setLocalDomain(). Using PHP on OS X, this defaults to "::1", which is rejected by the remote server. I've just added a line in my development configuration to set that:

$transport = Swift_SmtpTransport::newInstance('mail.pantsburger.com', 587);
if (SITE_ENV == SITE_ENV_DEV) {
    $transport->setLocalDomain('[127.0.0.1]');
}

I think this is also a bug with Swiftmailer - it really should be throwing an exception for something like this, rather than just listing each recipient as "failed".



来源:https://stackoverflow.com/questions/4362417/swiftmailer-smtp-transport-rejecting-local-ip-address

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!