title: Can't send mails in C# : Error in system.dll
body: <p>I'm trying this code in order to send to somewho user his password using the mail he enters.</p>
  
  <pre><code>SmtpClient client = new SmtpClient();
  client.Port = 587;
  client.Host = "smtp.gmail.com";
  client.EnableSsl = true;
  client.Timeout = 10000;
  client.DeliveryMethod = SmtpDeliveryMethod.Network;
  client.UseDefaultCredentials = false;
  client.Credentials = new System.Net.NetworkCredential("fzc.solutions@gmail.com", "********");
  //de qui, a qui, objet, sujet
  MailMessage mm = new MailMessage("bluepenlabs.aux@gmail.com", "fzc.solutions@gmail.com", "test", "test");
  mm.BodyEncoding = UTF8Encoding.UTF8;
  mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
  client.Send(mm);
  </code></pre>
  
  <p>Here is the error :</p>
  
  <blockquote>
    <p>Une exception non gérée du type 'System.Net.Mail.SmtpException' s'est
    produite dans System.dll</p>
    
    <p>Informations supplémentaires : Le serveur SMTP requiert une connexion
    sécurisée ou le client n'était pas authentifié. La réponse du serveur
    était : 5.5.1 Authentication Required. Learn more at</p>
  </blockquote>
  
  <p>I'll Translate here :</p>
  
  <blockquote>
    <p>An unhandled exception of type 'System.Net.Mail.SmtpException'
    occurred in System.dll</p>
    
    <p>Additional information: The SMTP server requires a secure connection
    or the client was not authenticated. The server response was: 5.5.1
    Authentication Required. Learn more at</p>
  </blockquote>
  
  <p>While I tried with two different gmails accounts, same error, I am certain that password is correct. When I change the port to 465 I get this error :</p>
  
  <blockquote>
    <p>An unhandled exception of type 'System.Net.Mail.SmtpException'
    occurred in System.dll
    Additional Information: The operation timeout expired.</p>
  </blockquote>
  
  <p>I got to setting Timeout to 10000, 20000, and even 100000 and still nothing !</p>
  
  <p>Please help thanks !</p>