Unable to send email using C# code and NodeJS
We are getting an exception saying that "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 165.254.168.48:25".
when we try to send email using c# Code. Following is sample code which we used to send mail.
- try
- {
- MailMessage mail = null;
- var from = "XXXXX@domainname.com";
- var to = "abc@domainname.com";
- using (mail = new MailMessage(new MailAddress(from), new MailAddress(to)))
- {
- mail.Subject = "Test Mail";
- mail.Body = "This is for testing SMTP mail from GMAIL";
- mail.To.Add(to);
- SmtpClient smtpMail = null;
- using (smtpMail = new SmtpClient("smtp.zoho.com", 465))
- {
- smtpMail.Port = 465;
- smtpMail.EnableSsl = true;
- smtpMail.Credentials = new System.Net.NetworkCredential("noreply@domainname.com", "testpassword");
- smtpMail.UseDefaultCredentials = true;
-
- smtpMail.Send(mail);
- Console.WriteLine("sent");
- Console.ReadLine();
- }
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
Please let us know if you need more information.