title: How to send email by using MailKit?
body: <p>According to the new google politics <a href="https://googleonlinesecurity.blogspot.de/2014/04/new-security-measures-will-affect-older.html" rel="noreferrer">https://googleonlinesecurity.blogspot.de/2014/04/new-security-measures-will-affect-older.html</a> I can't sent an email. "Less secure apps" are considered for google the application which don't use OAuth 2.0.</p>
  
  <p>I would like to use MailKit to solve this problem</p>
  
  <pre><code>var message = new MimeMessage();
  
  message.From.Add(new MailboxAddress("Joey Tribbiani", "noreply@localhost.com"));
  message.To.Add(new MailboxAddress("Mrs. Chanandler Bong", "mymail@gmail.com"));
  message.Subject = "How you doin'?";
  message.Body = new TextPart("plain"){ Text = @"Hey" };
  
  using (var client = new SmtpClient())
  {
     client.Connect("smtp.gmail.com", 587);
  
     ////Note: only needed if the SMTP server requires authentication
     client.Authenticate("mymail@gmail.com", "mypassword");
  
     client.Send(message);
     client.Disconnect(true);
  }
  </code></pre>
  
  <p>But I have got <code>An exception of type 'MailKit.Security.AuthenticationException' occurred in MailKit.dll but was not handled in user code.Additional information: Authentication failed.</code> </p>
  
  <p>I don't want to change my security settings. Because I want that everything will be secure. That's why I start to use MailKit rather than System.Net.Mail</p>
  
  <p>How can I fix it?</p>