系统网邮政SmtpException:操作已超时.asp.net使用godaddy托管发送邮件代码时出错
本文关键字:godaddy 出错 代码 使用 net SmtpException 操作 asp 超时 系统 | 更新日期: 2023-09-27 17:58:56
我使用以下代码来使用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);
}
我认为这是系统中著名的SSL问题。网邮件
系统。网使用SSL发送邮件,以根据端口465 进行身份验证
您应该使用一些外部库,或者等到Microsoft在框架版本中包含这些功能时再使用。
更改:
smtp.Timeout = 20000;
至
smtp.Timeout = 2000000;