1

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) {

        }
    }
Jim G.
  • 15,141
  • 22
  • 103
  • 166
  • You are using Port 25 which is non secure email. GMAIL is don't think supports non secure email any more. Check the gmail website for SMTP options. – jdweng Sep 01 '19 at 10:12
  • Try telnet to the port 25, 587 many service providers block outgoing port 25 (also try the other ports). – IamK Sep 01 '19 at 10:28

0 Answers0