Page 1 of 1

Intermittent Disconnects...

Posted: Mon Apr 28, 2008 12:06 pm
by iricketson
I've got a PHP script that sends out emails using SwiftMailer. For the most part it works fine, however I am running in to this intermittent problem:
There was a problem reading line 1 of an SMTP response. The response so far was:<br />[]. It appears the connection has died without saying goodbye to us! Too many emails in one go perhaps? (fsockopen: #0)
It doesn't seem to have a rhyme or reason; I'm able to send out batches of emails, emails with attachments, etc... Sometimes it will fail when just sending 1 email with no attachment or anything, but its completely random. I'm thinking this is more of a "server" related issue than it is a SwiftMailer issue, but I was hoping that someone might be able to give me some ideas.

I searched the forums here but didn't find too much helpful information on the subject.

Thanks for your help!

Re: Intermittent Disconnects...

Posted: Mon Apr 28, 2008 1:27 pm
by s.dot
Is this a 1&1 email server? Heh, that's the same message I used to get. It's a server related issue.

The one I was using said 99 emails in one batch, then you can send another batch. Problem was I bet they were expecting 99 connects and disconnects.. like using a while loop with the mail() function. Except I was using batchSend().. and I'd get that message after 300 or so emails.. no matter WHAT I tried.

Re: Intermittent Disconnects...

Posted: Mon Apr 28, 2008 5:46 pm
by iricketson
Nope, its not 1&1. Its a locally hosted CentOS5 box.

I'm just having a hard time isolating the problem, because I can send batches fine, single emails fine, and all of a sudden I might get that message. Even if its just a single email w/o any batch. I do have several installations of the same app on the server though, so is it possible that for some reason if 1 email is being sent and another tries to send at the same time, the error occurs? Kind of a legacy app, so its hard to tell.

Re: Intermittent Disconnects...

Posted: Mon Apr 28, 2008 7:12 pm
by Chris Corbyn
I just solved on of these for someone else today. Their sys admin has incorrectly set up an ACL in Exim which was sending a 550 response (correct) if a recipient's mailbox did not exist, but was then immediately closing the connection (INCORRECT). When an SMTP server sends a 550 response the client (Swift) should be able to just carry on to the next address and get a 250 response. If their are no more addresses to try the client should be able to send a "RSET" request and the server MUST send a "250" response. Neither of these scenarios were possible because the sys admin had set up exim to simply end the connection after sending the 550.

This is all specified in RFC 2821. If you know the address causing the problem you can easily replicate the issue if that's the same problem:

1. Open command line application.
2. Run "telnet smtp.servername.tld 25"
3. Issue the following commands one line at a time.

-----------
EHLO localhost
MAIL FROM: <your@address.com>
RCPT TO: <other@address.com>
QUIT
-----------

Replace the MAIL FROM address with your own, but keep the < angle brackets > in there.
Replace the RCPT TO address with the one which seems to be causing a problem, keeping the angle brackets there.

If you never get a chance to issue the QUIT command then the server is in violation of RFC 2821. The server should never close the connection in response to RCPT TO.

Re: Intermittent Disconnects...

Posted: Tue May 20, 2008 10:14 am
by iricketson
Chris,

I'm still having issues with this same error messge appearing in the logs. From your explanation, I think I understand what is happening, however the error that it sends (posted in the original message) appears to throw an error that cannot be not caught and handled as part of my mail transmisson.

Code: Select all

 
try
{
  // send email
}       
catch (Swift_Connection_Exception $e) 
{
  //handle error
}
catch (Swift_Message_MimeException $e) 
{
  //handle error
}
 
Are there any other methods to capture these types of errors so I can handle them on my own?

Re: Intermittent Disconnects...

Posted: Wed Jul 02, 2008 6:42 am
by Krizna
I have the same problem. Out of the blue I get the same error message as TS, thus abrubtly stopping my script.

I did the telnet thing Chris suggested, and this was my outcome:
telnet smtp.recipient.tld 25
MAIL FROM <info@mydomain.tld>
RCPT TO <info@recipient.tld>
QUIT

-- after about 10 seconds --

Trying x.x.x.x [my server's ip]...
Connected to smtp.recipient.tld.myserver.tld (x.x.x.x [my server's ip]).
Escape character is '^]'.
220 myserver.tld ESMTP

-- after about 20 seconds --

250 ok
451 DNS temporary failure (#4.5.1 - chkuser)
221 myserver.tld
Connection closed by foreign host.
So it seems the recipient's smtp server cannot be reached due to a dns problem. For the record: other mails are delivered fine, and after about 30 minutes the recipient's server is again listed correctly, so this is clearly a temporary problem with the recipient's server.

However, I wonder if our server and/or swiftmailer are coping with this correctly, because swiftmailer is under the impression the connection is lost, which isn't the case.

So can anyone tell me do to fix this? Or how I can catch this error so my script won't stop?

BTW: here's another person reporting this problem.

Thanks!

Re: Intermittent Disconnects...

Posted: Wed Jul 09, 2008 2:44 am
by Chris Corbyn
I'll try to cut down the number of these errors in future releases. As you can see, the problem is with the SMTP-server, but I can get Swift to deal with it a little more gracefully. For the most-part, a $swift->batchSend() call instead of a $swift->send() call would help.

Re: Intermittent Disconnects...

Posted: Fri Jul 18, 2008 11:47 am
by iricketson
Yes, I still get these errors quite often. It would be good if it would it didnt kill the whole batch every time something like this happens. Not sure what the exact issue is, but the DNS explanation could be something to look at.