title: authentication or decryption has failed when sending mail to GMail using SSL
body: <p>I'm referring to this <a href="http://csharp.net-informations.com/communications/csharp-smtp-mail.htm" rel="noreferrer">guide on C# SMTP mail</a>.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>MailMessage mail = new MailMessage();
  SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
  mail.From = new MailAddress("dave.stockinger@gmail.com");
  mail.To.Add("dave.stockinger@gmail.com");
  mail.Subject = "Test Mail";
  mail.Body = "This is for testing SMTP mail from GMAIL";
  SmtpServer.Port = 587;
  SmtpServer.Credentials = new System.Net.NetworkCredential("MyUserNameInGmail", "MyGmailPassWord");
  SmtpServer.EnableSsl = true;
  
  SmtpServer.Send(mail);
  </code></pre>
  
  <p>Unfortunately, there's an exception regarding SSL and I can't fix it:</p>
  
  <blockquote>
    <p>Unhandled Exception:
    System.Net.Mail.SmtpException: Message
    could not be sent. --->
    System.IO.IOException: The
    authentication or decryption has
    failed. --->
    System.InvalidOperationException: SSL
    authentication error:
    RemoteCertificateNotAvailable,
    RemoteCertificateChainErrors   at
    System.Net.Mail.SmtpClient.m__4
    (System.Object sender,
    System.Security.Cryptography.X509Certificates.X509Certificate
    certificate,
    System.Security.Cryptography.X509Certificates.X509Chain
    chain, SslPolicyErrors
    sslPolicyErrors) [0x00000] in
    :0    at
    System.Net.Security.SslStream+c__AnonStorey7.&lt;>m__A
    (System.Security.Cryptography.X509Certificates.X509Certificate
    cert, System.Int32[] certErrors)
    [0x00000] in :0<br>
    at
    Mono.Security.Protocol.Tls.SslClientStream.OnRemoteCertificateValidation
    (System.Security.Cryptography.X509Certificates.X509Certificate
    certificate, System.Int32[] errors)
    [0x00000] in :0<br>
    at
    Mono.Security.Protocol.Tls.SslStreamBase.RaiseRemoteCertificateValidation
    (System.Security.Cryptography.X509Certificates.X509Certificate
    certificate, System.Int32[] errors)
    [0x00000] in :0<br>
    at
    Mono.Security.Protocol.Tls.SslClientStream.RaiseServerCertificateValidation
    (System.Security.Cryptography.X509Certificates.X509Certificate
    certificate, System.Int32[]
    certificateErrors) [0x00000] in
    :0    at
    Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.validateCertificates
    (Mono.Security.X509.X509CertificateCollection
    certificates) [0x00000] in :0    at
    Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.ProcessAsTls1
    () [0x00000] in :0<br>
    at
    Mono.Security.Protocol.Tls.Handshake.HandshakeMessage.Process
    () [0x00000] in :0<br>
    at (wrapper
    remoting-invoke-with-check)
    Mono.Security.Protocol.Tls.Handshake.HandshakeMessage:Process
    ()   at
    Mono.Security.Protocol.Tls.ClientRecordProtocol.ProcessHandshakeMessage
    (Mono.Security.Protocol.Tls.TlsStream
    handMsg) [0x00000] in :0    at
    Mono.Security.Protocol.Tls.RecordProtocol.InternalReceiveRecordCallback
    (IAsyncResult asyncResult) [0x00000]
    in :0    --- End of
    inner exception stack trace ---   at
    Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback
    (IAsyncResult asyncResult) [0x00000]
    in :0    --- End of
    inner exception stack trace ---   at
    System.Net.Mail.SmtpClient.Send
    (System.Net.Mail.MailMessage message)
    [0x00000] in :0<br>
    at csharpdungeon.MainClass.Main ()
    [0x00000] in :0</p>
  </blockquote>