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

本秂侑毒 提交于 2019-11-27 23:31:08

问题


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 = "frommailid@site.com";
        // any address where the email will be sending
        var toAddress = "to@gmail.com";
        //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: pro@e-hotelspro.com";
        // 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);
    }

回答1:


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




回答2:


Just Change:

smtp.Timeout = 20000;

To

smtp.Timeout = 2000000;



来源:https://stackoverflow.com/questions/14828304/system-net-mail-smtpexception-the-operation-has-timed-out-error-in-asp-net-sen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!