`使用ZOHO SMTP配置发送邮件时,操作超时。例外

时间:2022-04-14 18:16:07

I am using ZOHO mail server for sending mails through my application. But its unable to connect to server and throws exception The operation has timed out.. Following is my code:

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

I also tried using port 587 as suggested here Send email using smtp but operation timed out using ZOHO. But still problem persists.

我也尝试使用端口587,如此处建议使用smtp发送电子邮件但操作使用ZOHO超时。但问题仍然存在。

Zoho SMTP Configuration help link: https://www.zoho.com/mail/help/zoho-smtp.html

Zoho SMTP配置帮助链接:https://www.zoho.com/mail/help/zoho-smtp.html

2 个解决方案

#1


0  

Time out problems are usually related to network, ports problems, I haven't experience sending emails using SSL or TLS methods but I'd check this too, of course I suppouse you changed the port number when you say you tried TLS.

超时问题通常与网络,端口问题有关,我没有使用SSL或TLS方法发送电子邮件的经验,但我也检查了这一点,当然我说你在尝试TLS时更改了端口号。

#2


0  

After trying all kinds of firewall/anti-virus/router port forwarding, port scanners, website port checkers I simply found out that with code almost identical to yours I was able to send mail successfully!

在尝试各种防火墙/防病毒/路由器端口转发,端口扫描程序,网站端口检查器之后,我发现代码几乎与您的相同,我能够成功发送邮件!

All you need to do is change smtp to: smtp.zoho.eu

您需要做的就是将smtp更改为:smtp.zoho.eu

and port to: 587

和港口:587

#1


0  

Time out problems are usually related to network, ports problems, I haven't experience sending emails using SSL or TLS methods but I'd check this too, of course I suppouse you changed the port number when you say you tried TLS.

超时问题通常与网络,端口问题有关,我没有使用SSL或TLS方法发送电子邮件的经验,但我也检查了这一点,当然我说你在尝试TLS时更改了端口号。

#2


0  

After trying all kinds of firewall/anti-virus/router port forwarding, port scanners, website port checkers I simply found out that with code almost identical to yours I was able to send mail successfully!

在尝试各种防火墙/防病毒/路由器端口转发,端口扫描程序,网站端口检查器之后,我发现代码几乎与您的相同,我能够成功发送邮件!

All you need to do is change smtp to: smtp.zoho.eu

您需要做的就是将smtp更改为:smtp.zoho.eu

and port to: 587

和港口:587