Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Net.Mail.SmtpException: The operation has timed out. error in asp.net send mail code using godaddy hosting

I am using following peace of code to send mail using godaddy hosting .

but its throw System.Net.Mail.SmtpException: The operation has timed out.

protected void sendmail()
    {
        var fromAddress = "[email protected]";
        // any address where the email will be sending
        var toAddress = "[email protected]";
        //Password of your gmail address
        const string fromPassword = "mypassword";
        // Passing the values and make a email formate to display
        string subject = "HI test mail ";
        string body = "From: [email protected]";
        // smtp settings
        var smtp = new System.Net.Mail.SmtpClient();
        {
            //smtp.Host = "relay-hosting.secureserver.net";
            smtp.Host = "smtpout.secureserver.net";
            smtp.Port = 80;
            smtp.EnableSsl = true;
            smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
            smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
            smtp.Timeout = 20000;
        }
        // Passing values to smtp object
        smtp.Send(fromAddress, toAddress, subject, body);
    }
like image 863
rahularyansharma Avatar asked Feb 12 '13 08:02

rahularyansharma


1 Answers

I think this is the famous SSL issue of System.Net.Mail

System.Net.Mail with SSL to authenticate against port 465

You should use some external library or wait until Microsoft include this features in a framework release

like image 106
giammin Avatar answered Sep 23 '22 09:09

giammin