我正在使用 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
最佳答案
超时问题通常与网络、端口问题有关,我没有使用 SSL 或 TLS 方法发送电子邮件的经验,但我也会检查一下,当然我假设你在尝试 TLS 时更改了端口号.
关于c# - 使用ZOHO SMTP配置发送邮件时出现`The operation has timed out.`异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32540747/