【发布时间】:2015-12-09 00:50:18
【问题描述】:
我正在使用ZOHO 邮件服务器通过我的应用程序发送邮件。但它无法连接到服务器并抛出异常The operation has timed out.。以下是我的代码:
public int sendMail(string from, string to, string subject, string messageBody) {
try {
SmtpClient client = new SmtpClient();
client.Port = 465;
client.Host = "smtp.zoho.com";
client.EnableSsl = true;
client.Timeout = 10000;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential(Username, Password);
MailMessage mm = new MailMessage(from, to, subject, messageBody);
mm.BodyEncoding = UTF8Encoding.UTF8;
mm.IsBodyHtml = true;
mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
client.Send(mm);
return 0;
} catch (Exception) {
throw;
}
}
我也尝试使用端口587,这里建议Send email using smtp but operation timed out using ZOHO。但问题依然存在。
Zoho SMTP 配置帮助链接:https://www.zoho.com/mail/help/zoho-smtp.html
【问题讨论】: