I am working on a Web Project. I want to create "Forget my password" system and send a mail to user when it needed but when i try this, it gives errors like SmtpException : Failure Sending Message, SocketException: Party did not properly respond or connection failed because connected host failed to respond and fails to send mail. I tried 2525, 25 and 587 ports. I also checked if i can connect smtp.gmail.com by mxtoolbox:
This is SMTP Email Server Test
This is SMTP DNS Test
and here is my code:
 protected void lblForPass_Click(object sender, EventArgs e)
 {
     SmtpClient client = new SmtpClient();
     client.DeliveryMethod = SmtpDeliveryMethod.Network;
     client.EnableSsl = true;
     client.Host = "smtp.gmail.com";
     client.UseDefaultCredentials = false;
     client.Port = 25;
     client.Timeout = 300000;
     System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("mytestmail@gmail.com", "1122334455");
     client.Credentials = credentials;
     MailMessage msg = new MailMessage();
     msg.From = new MailAddress("mytestmail@gmail.com");
     msg.To.Add(new MailAddress("mytestmail2@gmail.com"));
     msg.Subject = "Subject Test";
     msg.IsBodyHtml = true;
     msg.Body = string.Format("<html><head></head><body><b>Body Test</b></body>");
      try
      {
          client.Send(msg);
          ScriptManager.RegisterClientScriptBlock(this, GetType(), "Mail Status", "alert('Sended Successfuly')", true);
      }
      catch(Exception ex)
      {
          Exception ex2 = ex;
          string errorMessage = string.Empty;
          while (ex2 != null)
          {
              errorMessage += ex2.ToString();
              ex2 = ex2.InnerException;
          }
          string err = ex.Message;
          ScriptManager.RegisterClientScriptBlock(this, GetType(), "Mail Error", "alert('" +err+"')", true);
        }
    }  
Is there anything that i missed at this code block or do i need to check anything else? Thank you.


 
    