Post Pic

SmtpClient does not gracefully close the underlying TCP/IP connection

Some months back Tim Geyssens was kind enough to send me the source for his MailEngine addition to Umbraco before he released it on his blog. I made some customisations to the source to allow users to select templates and changed the filtering options slightly but other than that it worked jut fine for what I needed.

There was however one problem that became apparent when this was used in production. Sometimes, and apparently randomly the sending of mail would freeze when going to more than say 150 recipients. After a long time trying to track down the reason I stumbled across a post linking to the ‘SmtpClient does not gracefully close the underlying TCP/IP connection‘┬áissue on the Microsoft Connect website. I guessed it couldn’t do any harm to set the MaxTimeout property of the SmtpClient to 1 so I tried it and it seemed to work – so far so good however you should note the recent comment from someone with regards to using this method on IIS7.

Umbraco Certified Developer
SagePay Approved Partner
Creative Market