.NET Framework Developer Center > .NET Framework Forums > Network Class Library (System.Net) > SmtpClient.Send hangs - no network traffic to SMTP server

Unanswered SmtpClient.Send hangs - no network traffic to SMTP server

  • Thursday, February 25, 2010 4:13 AM
     
     

    Web searches for this issue kept turning up folks having firewall problems which is not the case here (can send Database Mail from SQL server without issues).

    I am writing a Windows console app in V Studio 2008 Pro which contains the following code, which I've stripped down to two lines trying to troubleshoot.

     

    SmtpClient mailServer = new SmtpClient("smtp.mydomain.com");
    mailServer.Send("nobody@mydomain.com", "myaddress@msn.com","test", "test");

    I execute the above code while I have Wireshark running and observe the following
      - My system sends a SYN packet to the SMTP server
      - The SMTP server replies with a SYN ACK
      - My system sends an ACK
      - The SMTP server replies with a response code 220
      - Another ACK is sent from my system to the SMTP server
      - Program hangs until the call times out and throws a SmtpException.

    So everything looks like what I'd expect until the SMTP server sends the response code - it is almost like SmtpClient is ignoring it and I'm really not sure why the second ACK is sent.

    The SMTP server does not authenticate, I checked in the debugger and the "Credentials" property is null and "UseDefaultCredentials" is false.

    Am I missing something obvious?

All Replies

  • Monday, March 01, 2010 9:06 PM
     
     

    Have you tried System.Net tracing? http://msdn.microsoft.com/en-us/library/ty48b824.aspx

    It may shed a bit more light on what's going wrong.

    Also, does the async code path behave any different?

  • Sunday, March 21, 2010 11:58 PM
     
     

    Thank for for your reply, sorry it took me a while to re-reply.

     

    Actually out of desperation I tried re-targeting my executable for the .Net 2.0 runtime and that seemed to fix my problem. No idea why, but whatever the reason the fix is good enough for me.

  • Saturday, November 20, 2010 4:20 AM
     
     

    Yikes, sorry it took me so long to follow up again everyone. I'm pretty sure my problem went away on it's own - out of desperation I retargeted my application to the .Net 2.0 framework and everything started working.

    I have no faith whatsoever that using an older framework actually changed anything, I think something on the mail server must have been fixed at the same time I was tinkering with my code.