c# - System.Net.Mail.SmtpException : The operation has timed out. 错误在asp.net发送邮件代码使用godaddy托管

标签 c# asp.net sendmail smtpclient

我正在使用以下代码和平使用 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);
    }

最佳答案

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

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

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

关于c# - System.Net.Mail.SmtpException : The operation has timed out. 错误在asp.net发送邮件代码使用godaddy托管,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14828304/

相关文章:

c# - 在网络中断时使用 Directory.Exists 在网络文件夹上

perl - sendmail 如何从任何域发送电子邮件?

php - 禁用 PHP 邮件功能的警告

c# - 使用 C# 在 Excel 中合并单元格

c# - 如何为每个 StackPanel 项目设置单独的工具提示?

c# - 我有什么选择可以从 .NET 中的代码生成 PDF 报告以获取科学数据 (winforms)

asp.net - 防止数字以指数表示法显示的更简单方法

c# - 在 aspx 页面中加载一个又一个控件

asp.net - 通过 web.config 设置拒绝目录中的所有文件

sendmail - mailx 和 sendmail 之间的区别?