I am using Symfony + SwiftMailer and getting the following error from SwiftMailer:
500 | Internal Server Error | Swift_TransportException
Expected response code 220 but got code "", with message ""
and can t figure out why. I am using hMailServer on my local machine, and have setup my factories.yml file (as I m using Symfony) as follows:
mailer:
class: sfMailer
param:
logging: %SF_LOGGING_ENABLED%
charset: %SF_CHARSET%
delivery_strategy: realtime
transport:
class: Swift_SmtpTransport
param:
host: splodge.loc
port: 25
encryption: ~
username: ~
password: ~
I m using the following code to send:
$message = $this->getMailer()->compose(
noreply@splodge.loc ,
info@splodge.loc ,
Reset Password ,
Message
);
$result = $this->getMailer()->send($message);
Has anyone had an issue like this before?
I have found that sometimes, and very randomly, the send goes through, but every other time, I get the above error message. So constantly refreshing the page that sends the mail, fails unpredictably, and as the code sometimes works, it s kinda hard to figure out what s wrong.
Any help will be highly appreciated!
Further investigation has shown that the SMTP server does send [220 localhost ESMTP], but after taking a look at hMailServer logs, I discovered the following:
"TCPIP" 5232 "2010-06-16 11:40:54.043" "TCPConnection - Posting AcceptEx on 0.0.0.0:25"
"DEBUG" 5232 "2010-06-16 11:40:54.043" "Creating session 51"
"SMTPD" 5232 51 "2010-06-16 11:40:54.043" "127.0.0.1" "SENT: 220 localhost ESMTP"
"DEBUG" 5296 "2010-06-16 11:40:54.199" "The read operation failed. Bytes transferred: 0 Remote IP: 127.0.0.1, Session: 51, Code: 10054, Message: An existing connection was forcibly closed by the remote host"
"DEBUG" 5296 "2010-06-16 11:40:54.199" "Ending session 51"
Could it be that SwiftMailer is HELO/EHLOing too early, and that this is simply a time issue? Can I delay the HELO transmission a bit?
The good logs, when the thing actually sends looks as follows:
"TCPIP" 5232 "2010-06-16 11:42:21.278" "TCPConnection - Posting AcceptEx on 0.0.0.0:25"
"DEBUG" 5232 "2010-06-16 11:42:21.294" "Creating session 54"
"SMTPD" 5232 54 "2010-06-16 11:42:21.294" "127.0.0.1" "SENT: 220 localhost ESMTP"
"SMTPD" 5224 54 "2010-06-16 11:42:21.294" "127.0.0.1" "RECEIVED: EHLO splodge.loc"
So it has to be to do with the HELO/EHLO acknowledgement. Please advise! :)