I sometimes get an application exception: Unable to read data from the transport connection: net_io_connectionclosed.
I'm unable to reproduce consistently, and usually retrying the email fixes it.


korggy wrote Aug 27, 2011 at 6:19 PM

I am getting this too. The exception detail follows, I'll try to create a test app that reproduces the problem.

System.Net.Mail.SmtpException: Failure sending mail. ---> System.IO.IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.DelegatedStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.BufferedReadStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine)
at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller)
at System.Net.Mail.CheckCommand.Send(SmtpConnection conn, String& response)
at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from)
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
--- End of inner exception stack trace ---
at System.Net.Mail.SmtpClient.Send(MailMessage message)

wrote Feb 28, 2012 at 6:36 PM

WorkAByte wrote Feb 28, 2012 at 6:37 PM

not consistent for me, happens same code block less than 50% of the time.

wrote Feb 28, 2012 at 7:09 PM

wrote Mar 29, 2012 at 4:17 PM

ryanfinken wrote Mar 29, 2012 at 4:19 PM

I am having the exact same issue and it is sporadic for me as well.

gleeds wrote Jun 13, 2012 at 6:30 PM

I have run into this issue too, it happens pretty consistently if you send several emails in rapid succession. I'm testing a windows service that sends batches of emails and I usually have this happen after a few emails.

wrote Jun 13, 2012 at 6:30 PM

wrote Aug 7, 2012 at 11:25 AM

bsmithza wrote Aug 7, 2012 at 1:57 PM

I also had this problem. It looks like it's related to the number of emails you save in smtp4dev and consequently the memory usage of smtp4dev, and possibly the amount of available memory on your machine (I did not have much available after SMTP4Dev was running).

My bulk mailing app handles large volumes ( a few thousand) with small attachments so I set the smpt4dev to keep 10000 emails for testing purposes. It handles SMTP errors returned, so starts a new smtp session and re-sends the email which then succeeds. But the important thing is I can then see this error occurring repeatedly and at random, although the trend is that the longer smtp4dev runs it becomes more frequent.

I found that this occurs especially once a high volume of emails (a few hundred) has been sent and saved in smpt4dev. The smpt4dev executable size in memory grows to around 400MB depending on the email size. Once I had about 1000 saved emails it was only managing to send 1 email before generating this error and having to start a new smtp session.

While my bulk mailer was running and this error was occurring I deleted most of the saved emails in smtp4dev and immediately the next session handled 158 mails before encountering the same problem.

I saw the 2.1 alpha release has a facility to instead save the messages to a folder, so I installed this and set it to use folder. Not only do I not get the error anymore but I also found the email throughput was 10 fold faster. I also noticed that the smtp4dev executable is nowhere near as large as 400MB after processing 1000 emails, its around 25MB.

So its fair to say this issue is really addressed by the 2.1 Alpha release. And a big thumbs up for the alpha release :)

wrote Feb 22, 2013 at 1:30 AM

wrote Apr 4, 2013 at 8:58 AM

wrote Sep 18, 2013 at 7:41 AM

peterrow wrote Oct 24, 2013 at 4:05 PM

This is a very annoying issue. I get the same exception as korggy.
I've tried:
  • stop listening, start listening
  • quitting smtp4dev, restarting
  • restarting IIS and quitting smtp4dev and restarting
    ... in all cases the very next email my web app attempts to send - bang exception at the point at which it SmtpClient.Send() just like in the stack trace.
Bump this for a fix.
About to try a VS studio restart followed by a machine reboot.

wrote Oct 28, 2013 at 4:59 PM

noral wrote Nov 6, 2013 at 12:58 AM

I just spent two days trying to figure out what was wrong with my code and as it turns out it was this utility causing issue.

This is a wonderful utility - please fix.

rnwood wrote Nov 6, 2013 at 8:02 AM

Hi to everybody with this error.

Please can you try the following release and let me know if this fixes it:

cipsoftware wrote Feb 5, 2015 at 11:12 AM

I believe 2.1 alpha 1 has fixed this. This issue did not occur anymore in my (small) test, whereas it occurred quite frequently in 2.0.9.