none
IOException during sending mail on productive server RRS feed

  • Question

  • Hi

    I get the follow exception, when I try to send a mail(SMTPClient from .NET) on our productive server(IIS) over an exchange server of an customer. When I send the mail with an SMTP-Server of my provider, it's ok. When I send the mail with the server of the customer with telnet(from Server), it's also ok. I can also send mail from my local IIS-Installation over the customer SMTP server.

    An other problem is with some pdf's to send in an email with SMTPClient. When I resave the pdf with my pdf reader, sending is possible. The problem is allways on this productive server(Win 2008 R2). The pdf-send-problem is since about 3 weeks(possible after the last microsfot hotfix updates??).

    Has someone any ideas?

    Best regards

    Christoph


    System.Net.Mail.SmtpException: Failure sending mail.
    ---> System.IO.IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
    ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond    
     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.AuthCommand.Send(SmtpConnection conn, String message)  
                     at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)  
                        at System.Net.Mail.SmtpClient.Send(MailMessage message)   
                          --- End of inner exception stack trace ---  
                             at System.Net.Mail.SmtpClient.Send(MailMessage message)  

    • Moved by Mike Feng Tuesday, January 29, 2013 2:57 AM
    Friday, January 25, 2013 9:48 PM

All replies

  • Often SMTP fails if a firewall blocks the port number.  With SMTP depending on the mail server three different prots can be used (it depends on the type of security bein gused).  Each security method uses a different poirt number.   The mail server could also have changed the security they are using and you will need to maodify your code to match the latest chenages at the mail server.

    Did you recompile since it last worked?  There are some default parameters that are diffferent with SMTP between Net 3.5 and Net 4.0.faulted to use Network for the connection method while 4.0 doesn't.  So you have to add the following

    SmtpClient client = new SmtpClient();
                client.DeliveryMethod = SmtpDeliveryMethod.Network;


    jdweng

    Saturday, January 26, 2013 12:02 PM
  • Hi Joel

    The Port can't be problem. With telnet to the mailserver and the same port it's ok. From local installation of the web it's also ok, only on the productive server, theres a problem to this one server.

    At other customers on this server, i've the problem with some pdf's which generates the same error. When I save the pdf again, the sending is ok.

    Sunday, January 27, 2013 7:02 PM
  • Make sure you delete the cookies and temp files from the IE browser.  Sometimes after an update the protocol changes slightly and any history informationm must be cleared.  Your connection between clients and server go through multiple hops (servers and routers) and port blocking can occur any place in the connection.  If the connection works using Telnet and not with the NET library than you are correct that it isn't the port number being blocked but a setting that is different between Telnet connection and your application software.  Normally I use a tool like wireshark to compare the good and badd connection to isolate the problem.  I also make sure inbetween tests I delete the cookies.  With SMTP often the problem is the security options (SSL or TLS) or a changge to a proxy server.

    jdweng

    Monday, January 28, 2013 10:18 AM
  • Check for the rights on PDFs you are trying to send. Probability is that you are not having enough rights to access the file from your code, try running it with admin rights.

    You can set it to run as an administrator every time by changing its properties.


    Thanks, Durgesh Chaudhary. http://home.techphernalia.com

    Monday, January 28, 2013 10:47 AM
  • The mailconfiguration is also set to port 25. I use the same configuration an my local installation and all is ok. I've compunctions to install wireshark on an productive server.

    To analyse the pdf-problem, i've installed an my local PC an mailserver, used this mailserver in our application to send mail and checked with log and local installed wireshark the communicatin. During sending of the mail, the SMTP-lines suddenly stopped without more infos, why.

    The pdf's are uploaded with the web application to the server and then sended by mail. So, the access rights are allways the same and when I save the pdf again(the size is about 20k higher at 190kb), sending is processed.

    Christoph

    Monday, January 28, 2013 12:18 PM
  • SMTP could be using port forwarding and redirecting to a different port number.  This is normal if SSL or TLS encryption is being used.  Also another IP address could be used so make sure you check all the protocols not just the SMTP.

    jdweng

    Monday, January 28, 2013 12:26 PM
  • Hi

    Here is an wireshark-Log at the last seconds bevore stop. With the pdf wich can be send, I've seen the TCP Dup ACK but then, sending isn't stopped.

    Monday, January 28, 2013 9:06 PM
  • The problem is occuring earlier.  The last SMTP packet gets resent 5 times with no ack which is causing the connection to terminate.  There is also a duplicate ack earlier which shouldn't be happening.  Try using PING to see if there is any issues with the route.  YOu can type ping/? to get a list of options.  Try sending some long messages and see if you are loosing any data or the return time is long.  Also check the number of hops.  You may have some bad hardware or ethernet cables in the connection.  Also a server may be heavily loaded which may produce these errors.  It still could be a firewall blocking data in one direction or some sort of routing loop.


    jdweng

    Monday, January 28, 2013 10:43 PM
  • Some firewalls will block certain extension types like pdf, exe, or zip.  Try sending a straight text file and see what happens

    jdweng

    Monday, January 28, 2013 10:45 PM
  • Hi

    Sending of the most other pdf's(also lagrger) is no problem. Ping to this Mailserver seems to be blocked.

    With telnet, I can send mail over this mailserver. 

    It's an virtual server in a datacenter. I've done now a small .net console app. When I start it on my PC, als is ok. When I start it on the server, the same exception. When I change the mailserver, it's also ok.

    I don't know, if the problem with some pdf's and the problem with sending every mail to one customer mailserver are same or different. The second problem could depend on the customer Exchange server, but why can I send from my pc?

    Tuesday, January 29, 2013 1:33 PM