title: ASP.net MVC Sending Mail
body: <p>This is my code to send mail (test code):</p>
  
  <pre><code>//sending mail
  var message = new System.Net.Mail.MailMessage();
  message.From = new MailAddress("J2v@gmail.com");
  message.To.Add(model.Mailag);
  message.Subject = "Valdation d'inscription";
  message.Body = "Votre inscription a été valide voici vos cordonne de conexion ID user : "+model.Idag+" Password : "+user.password;
  var client = new  System.Net.Mail.SmtpClient
  {
      Host = "smtp.gmail.com",
      Port = 587,
      EnableSsl = true,
      UseDefaultCredentials = false,
      Credentials = new NetworkCredential("", "")
  };
  client.Send(message);
  </code></pre>
  
  <p>When I try it I got this error:</p>
  
  <blockquote>
    <p>SMTP server require secured connexion or you are not connected. Server response was :5.5.1 Authentication Required. Learn more at</p>
  </blockquote>
  
  <p>on this line: <code>client.Send(message);</code></p>