C# `操作已超时。`使用ZOHO SMTP配置发送邮件时出现异常
我使用邮件服务器通过我的应用程序发送邮件。但它无法连接到服务器并引发异常C# `操作已超时。`使用ZOHO SMTP配置发送邮件时出现异常,c#,.net,email,smtp,zoho,C#,.net,Email,Smtp,Zoho,我使用邮件服务器通过我的应用程序发送邮件。但它无法连接到服务器并引发异常操作已超时。。以下是我的代码: public int sendMail(string from, string to, string subject, string messageBody) { try { SmtpClient client = new SmtpClient(); client.Port = 465; client.Host = "smtp.zoho.
操作已超时。
。以下是我的代码:
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
。但问题依然存在
Zoho SMTP配置帮助链接:超时问题通常与网络、端口问题有关,我没有使用SSL或TLS方法发送电子邮件的经验,但我也会检查一下,当然我支持您在尝试TLS时更改端口号。在尝试各种防火墙/防病毒/路由器端口转发后,端口扫描器,网站端口检查器我只是发现,与你的代码几乎相同,我能够成功地发送邮件 您只需将smtp更改为: smtp.zoho.eu 港口至: 587