I am using a SmtpClient library to send the emails using a below code :
SmtpClient smtpclient = new SmtpClient();
smtpclient.Host = "hostname";
smtpclient.Port = 465;
smtpclient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpclient.UseDefaultCredentials = false;
smtpclient.EnableSsl = true;
smtpclient.Credentials = new NetworkCredential("User", "Pass);
smtpclient.Send("from@hostname", "to@hostname", "Subject", "Body");
Above code works fine in the test environment, but when I use it on production SMTP servers, the code fails with a SmtpException "Failure sending mail." with the inner IOException "Unable to read data from the transport connection: net_io_connectionclosed".
I have also confirmed that the firewalls are not the issue. A port opens just fine between a client and a server. I am not sure at all what else could throw above error.