.Net 4.0 smtpclient - Unable to read data from the transport connection: net_io_connectionclosed.


  • I had an ASP.NET application upgraded from .net 3.5 to .net 4.0.  Everything works fine in the development environment.  When I moved it to a test environment, SendMail() started returning the following error: "Unable to read data from the transport connection: net_io_connectionclosed.".  Keep in mind that that in 3.5 it works in the dev and test environments without any issues.

    The SMTP server is not localhost, it is a 3rd party server. 



    			<smtp deliveryMethod="Network" from="email address">
    				<network host="smtp server" userName="myemail" password="mypassword" port="80" defaultCredentials="false" />

    Code Snippet:

        public void SendMail(Email eml)
          MailMessage message = new MailMessage();
          message.Subject = eml.Subject;
          message.Body = eml.Body;
          using (SmtpClient client = new SmtpClient())



    Unable to read data from the transport connection: net_io_connectionclosed.
      at System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer, Int32 offset, Int32 read, Boolean readLine)
      at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine)
      at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller)
      at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)
      at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)
      at System.Net.Mail.SmtpClient.GetConnection()
      at System.Net.Mail.SmtpClient.Send(MailMessage message)

    Wednesday, April 20, 2011 9:33 PM

All replies

  • Exception means you have no connection between client and SMTP server. It looks like your problem is related to mail network setting configuration. Either value in the config file is wrong. Or it is using different config file than you edited. Try configuring SmtpClient from code, not from config file, to debug. Also turning on .NET tracing may help as well.

    Wednesday, July 27, 2011 10:32 PM
  • Yup, enable .NET Network Tracing (e.g. http://blogs.msdn.com/b/feroze_daud/archive/2005/05/12/416922.aspx )  You'll very likely see an error message from the SMTP server or maybe some sort of firewall inbetween.  The error message will likely show what's wrong.

    http://www.alanjmcf.me.uk/ Please follow-up in the newsgroup. If I help, mark the question answered
    Friday, July 29, 2011 1:43 PM
  • I have the exact same error.  Sometimes it works sometimes not.
    Now I did look at the link and all I see is a config file.  what do I do with that, where do I put this and where do I look for logs or trace after that ?

    I'm using a Silverlight 4 application which all the code for sendting email is obviously in the WCF service
    I tried providing credentials with no success.

    Marcheur extrême...

    Monday, May 28, 2012 4:33 PM
  • It appeared that the Exchange server database was getting full.
    A technician splitted it and everything was fine.

    Marcheur extrême...

    Sunday, June 17, 2012 10:07 PM