title: AuthenticationException when tryign to connect to mail server using MailKit
body: <p>I am using <code>MailKit</code> to try and send email though an exchange server via SMTP but when I try to connect I get the following error:</p>
  
  <blockquote>
    <p>An exception of type
    'System.Security.Authentication.AuthenticationException' occurred in
    MailKit.dll but was not handled in user code</p>
    
    <p>Additional information: The remote certificate is invalid according to
    the validation procedure.</p>
  </blockquote>
  
  <p>Googleing this brings up a lot of stuff about Gmail or as part of other error messages (like FTP or web api requests and such). I have talked with the IT guys and it is not a self-signed cert and we don't require authentication (in fact the BugZilla instance I admin is setup with the same settings and works fine). What am I doing wrong or how can I get more details to further troubleshoot?</p>
  
  <pre><code>using (var Client = new SmtpClient())
  {
      Client.Connect("mail.address.com", 587, false);
      Client.AuthenticationMechanisms.Remove("XOAUTH2");
      Client.Send(Message);
      Client.Disconnect(true);
  }
  </code></pre>
  
  <p>Edit: I have verified with IT that it is the same cert used in IIS that hosts the <code>mail.address.com domain</code> as well as in exchange. I have also installed it as a trusted root but still get the same error.</p>
  
  <p>Edit 2: If I update the code to <code>Client.Connect("mail.address.com", 587, true);</code> then I get the error:</p>
  
  <blockquote>
    <p>An exception of type 'System.IO.IOException' occurred in >System.Private.Networking.dll but was not handled in user code</p>
    
    <p>Additional information: The handshake failed due to an unexpected packet format.</p>
  </blockquote>