3

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:

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.

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

Community
  • 1
  • 1
Aishwarya Shiva
  • 3,460
  • 15
  • 58
  • 107

2 Answers2

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.

Leskyam
  • 19
  • 4
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

and port to: 587

marto
  • 420
  • 1
  • 4
  • 15