voodoodyne / subethasmtp

SubEtha SMTP is a Java library for receiving SMTP mail
Other
344 stars 138 forks source link

Client timeout #30

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The attached patch provides a simple timeout mechanism in the SMTPClient 
class. I have run into a relatively popular mail service, libero.it, which 
has at least two MTAs behaving incorrectly. They also have several good 
ones. The bad MTAs wait before sending the welcome message until the 
client sends at least a single character. But the client of course won't 
send any character, because it is waiting for the welcome message. The 
connection hangs forever. The patch works according to my test: SMTPClient 
timeouts, and the server eventually finds a good libero.it MTA.

RFC 5321 recommends configurable and different timeout values, depending 
on the command. The patch is more primitive, it applies the longest of 
these timeout values, 10 minutes. If it becomes necessary, it wouldn't be 
difficult to create an interface covering the timeout mechanism, following 
the Strategy pattern. An implementation could check the command to be 
sent, and if it recognizes it, then it sets the SO_TIMEOUT accordingly, 
otherwise it sets a default value.

The patch also sets the connection timeout, this is only for completeness, 
as I see it does not really necessary. Windows timeouts within a few 
seconds, Ubuntu after 3 minutes. So the set value, 5 minutes, never kicks 
in. 

Original issue reported on code.google.com by hontvari@flyordie.com on 3 May 2010 at 11:36

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by lhori...@gmail.com on 2 Nov 2010 at 6:16

GoogleCodeExporter commented 9 years ago

Original comment by hontvari@flyordie.com on 28 Feb 2011 at 2:04