Question

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?

Was it helpful?

Solution

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".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top