cancel
Showing results for 
Search instead for 
Did you mean: 
Go to solution
Highlighted

Cannot send from Godaddy Email from C# ASPX web app

I am trying to send emails from a  Godaddy email account account@company.com.au from a C#  ASPX Web application project using the following code:

SmtpClient smtpClient = new SmtpClient("smtpout.secureserver.net", 25);

                smtpClient.UseDefaultCredentials = false;
                smtpClient.Credentials = new System.Net.NetworkCredential("account@company.com.au", "password");
                smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
                smtpClient.EnableSsl = false;
                MailMessage mail = new MailMessage();

              
                mail.From = new MailAddress("account@company.com.au", "Company");
                mail.To.Add(new MailAddress("simonkravis@bigpond.com"));
                mail.Subject = "Test";
                Attachment data = new Attachment(file);
                
                mail.Body = "Your file  " + file + " is attached";
                mail.Attachments.Add(data);
                smtpClient.Send(mail);

but the mail send operation times out. I have tried using port number 587 with EnableSSL = true with the same result. The file attachment is 100 kBytes in size.

2 REPLIES 2
Solution

Re: Cannot send from Godaddy Email from C# ASPX web app

Received some very useful help from GoDaddy support which suggested using port 80 with no ssl as shown below:

 

                SmtpClient smtpClient = new SmtpClient("smtpout.secureserver.net", 80);
                smtpClient.UseDefaultCredentials = false;
                smtpClient.Credentials = new System.Net.NetworkCredential("GoDaddy Email address", "GoDaddy Email Password");
                smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
                smtpClient.EnableSsl = false;
				
                MailMessage mail = new MailMessage();
                mail.From = new MailAddress("GoDaddy Email address", "Name for email");
                mail.To.Add(new MailAddress("destination email address"));
                mail.Subject = "Subject";
                Attachment data = new Attachment("FilePath to Attach");
                mail.Attachments.Add(data);                 
                data.Name ="Name to give to attachment;
                mail.Body = "Mail Body";
 
                smtpClient.Send(mail);

This worked OK

Re: Cannot send from Godaddy Email from C# ASPX web app

Still does not work for me locally in development mode - works in release mode on godaddy server.

 

get exception 

 

Unable to read data from the transport connection: net_io_connectionclosed.

 

private void SendMail(string to, string subject, string body)
{
#if DEBUG
var client = new SmtpClient("smtpout.secureserver.net", 80);
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential(email_address, email_password);
client.EnableSsl = false;
client.DeliveryMethod = SmtpDeliveryMethod.Network;

#else
var client = new SmtpClient("relay-hosting.secureserver.net");
#endif
MailMessage message = new MailMessage(email_address, to);
message.Subject = subject;
message.Body = body;
message.IsBodyHtml = true;
client.Send(message);
}