I am getting the following error
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 74.125.24.108:25
with error code 10060
I have tried using different ports 465
and 587
both didn't work. Also tried enabling and disabling ssl it didnt work. Still getting the same error.
Here is my code:
public static void SendMail(string body)
{
try
{
MailMessage mail = new MailMessage();
mail.To.Add("toaddr@gmail.com");
mail.From = new MailAddress("fromaddr@gmail.com");
mail.Subject = "test";
mail.Body = body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 25);
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential("fromaddr@gmail.com","password");
smtp.Send(mail);
}
catch (Exception ex) {
}
}