Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a mail compose screen where user can send mails to candidates when i send mail from my local system it works fine.

But mail sending failed in Liver server.
It says:
Unable to read data from the transport connection: An established connection was aborted by the software in your host machine


Here is my code in compose screen.
C#
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
           
            client.UseDefaultCredentials = false;
            client.Credentials = new System.Net.NetworkCredential("xyz@xyz.com", "xxxxx");
            client.Port = 587;
            client.Host = "smtp.gmail.com";

            client.EnableSsl = true;
            System.Net.Mail.MailMessage MyMsg = new System.Net.Mail.MailMessage();

            try
            {
               // MyMsg.From = new System.Net.Mail.MailAddress(txtFrom.Text.Trim());
                MyMsg.From = new System.Net.Mail.MailAddress("", "Admission - xyz@xyz.com");
               
                MyMsg.ReplyTo = new System.Net.Mail.MailAddress("", "Admissions - xyz@xyz.com");
            }
            catch (Exception ex)
            {
                lblStatus.Text = "Please enter the From: address properly";
                return;
            }


What I have tried:

mail sent successfully from development system.but failing in live server.
Posted
Comments
[no name] 12-Apr-17 14:15pm    
Most of the cases this exception indicates something on your machine is blocking your connection. Try disabling firewall/antivirus for testing purpose only if it worked you probably need to find a way to allow it with enabled firewall/antivirus.
khaleelsyed 23-Mar-18 7:03am    
thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900