Email sending using others’ smtp server should done asynchronously

SMTP access provided by 3rd-party sponsors such as Godaddy can be very unreliable. It may take seconds to setup a TCP connection or read and write data. 

As a result, the thread of sending an email may be blocked.  In return, if this thread is a user thread, i.e., created to serve a user’s request, the user can see unacceptable response latency.

You need to do the email sending work in a async way.  Set up a thread pool only for this dirty work.

In addition, you may also want to set up timeout for SMTP connections. Rather fail some emails than have your thread pool run out if all threads are blocked due to poor SMTP connections. 

To setup timeout, you can,

	

 
		
		
		
			
				...
				6000
				6000
			
		
....


Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.