Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29745

How to troubleshoot random error while sending email from ASP.NET website

$
0
0

I send emails from ASP.NET (4.0) website:

SmtpClient mySMTPClient = new SmtpClient();
mySMTPClient.UseDefaultCredentials = false;
mySMTPClient.Host = "email.privateemail.com";
mySMTPClient.Port = 465; //I also tried 587 and none of them
mySMTPClient.Credentials = new System.Net.NetworkCredential("contact@xxxxxx.com", "xxxxxxxxxx");
mySMTPClient.EnableSsl = true;
mySMTPClient.DeliveryMethod = SmtpDeliveryMethod.Network;
mySMTPClient.Send(email);

I send a dozen of emails / day and not in batch or in loop. Only about half of them are sent. The other fail with error:

ERROR MESSAGE: Failure sending mail.
INNER EXCEPTION: System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   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.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)

The failing emails are random. I don't have a pattern.

Windows server 2008 SP2 build 6002 Firewall PfSense - engineer says rules are configured properly, otherwise all emails would fail. 3rd part email provider: they say everything is configured properly with them and they cannot make any modification on their side anyways.

I am not a network engineer and I don't have one. My question is, what do I do to find the root cause so I can address it?

By now I tried Process Monitor but it doesn't help me (or I don't know how to look).

I found several articles on this problem, none help me by now as their solutions don't apply to my context (I tried some with no success).

Thank you


Viewing all articles
Browse latest Browse all 29745

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>