13

我正在使用以下代码和平来使用 godaddy 托管发送邮件。

但它的投掷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);
    }
4

2 回答 2

9

我认为这是 System.Net.Mail 著名的 SSL 问题

System.Net.Mail 使用 SSL 对端口 465 进行身份验证

您应该使用一些外部库或等到 Microsoft 在框架版本中包含此功能

于 2013-02-12T09:32:26.927 回答
-4

只是改变:

smtp.Timeout = 20000;

smtp.Timeout = 2000000;

于 2014-04-22T14:12:56.117 回答