c# - 使用ZOHO SMTP配置发送邮件时出现`The operation has timed out.`异常

标签 c# .net email smtp zoho

我正在使用 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/

相关文章:

c# - UWP 应用 : FileOpenPicker PickSingleFileAsync() can't await

c# - 如何获得霍夫曼码的长度

c# - 使用 C# 驱动程序在 MongoDB 中搜索对象数组

.net - 如何让一个用户组件成为WinForms中数据绑定(bind)的数据源?

c# - OpenCV - 如何检测和测量两帧之间的角度?

.net - 在 .NET 核心中查找 2 个坐标之间的距离

c# - DLL 不能在 C# 中运行

email - 通过 ember 发送电子邮件?

c# - 通过 C# 网页发送大量电子邮件的最佳方式是什么?

linux - 使用命令行检查新电子邮件