Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
I am trying to send email by using ASP.NET C# code. My website is hosted in godaddy server. It gives this error: Unable to read data from the transport connection: net_io_connectionclosed.

C#
using System.Net.Mail;
using MailMessage = System.Net.Mail.MailMessage;

protected void but_forgot_Click(object sender, EventArgs e)
{
MailMessage mail = new MailMessage();
mail.To.Add(txt_email.Text);
mail.From = new MailAddress("no-reply@abc.com");
mail.Subject = "Recovery Mail";
mail.Body = "Hello " + name + ", your recovery password is given below:" + "\n\nEmail: " + email + "\n\nPassword: " + password;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtpout.asia.secureserver.net";
smtp.Credentials = new System.Net.NetworkCredential("no-reply@abc.com", "password");
smtp.EnableSsl = false;
smtp.Port = 25;
smtp.Send(mail);
}
Posted
Updated 2-Feb-22 3:38am
v3
Comments
Herman<T>.Instance 5-Dec-14 6:27am    
which line throws the exception?
Raj Negi 5-Dec-14 6:37am    
smtp.Send(mail);

Refer -
Cannot get email to work with GoDaddy email SMTP
[^]. Implement this.
Quote:
Symptoms

Using GoDaddy SMTP server smptout.secureserver.net email errors occur such as: Mail Error occurred - Exception=Failure sending mail. Unable to read data from the transport connection: net_io_connectionclosed.
Cause

GoDaddy is blocking email relay from most 3rd party hosting providers.
Solution

Use the following SMTP settings for the GoDaddy email server:

Mail Server DNS = relay-hosting.secureserver.net
Mail Server TCP Port = 25


If this won't work, I guess you have to check with the GoDaddy Support team.
 
Share this answer
 
Comments
Raj Negi 5-Dec-14 7:46am    
It works. Thanks a lot Sir. :)
Most Welcome buddy. :)
Member 10113354 25-Apr-17 7:11am    
Thanks a lot
Most welcome :)
Try This..

C#
SmtpClient LocalClient = new SmtpClient();
            MailMessage Mail = new MailMessage();
            Mail.To.Add("ToEmail");
            Mail.From = new MailAddress("fromEmail");
            Mail.Body = "Test Message";
            Mail.Subject = "Mail Local";
          //  LocalClient.Port = 25;
           // LocalClient.Host = "127.0.0.1";
            LocalClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
            LocalClient.Credentials = new NetworkCredential("fromEmail", "Password");
            LocalClient.Send(Mail);
 
Share this answer
 
v2
its a framework issue, moving your project to framework 4.6 will resolve the issue.
 
Share this answer
 
Comments
Richard Deeming 2-Feb-22 9:27am    
Aside from the fact that 4.6 was released after the question was posted, if you'd read the accepted solution, you'd see that your suggestion clearly isn't the solution.
Member 10575951 10-Feb-22 4:05am    
yes it is working after changing framework 4.5 to 4.6.1
Phahad Mirza 2-Dec-22 1:15am    
changing framework also worked for me.

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