title: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated
body: <p>I'm trying to send email with my website's address from a C# application.<br>
  This worked fine for several months until recently. (maybe my provider changes some things or someone else changed settings)  </p>
  
  <p>Here's the code:  </p>
  
  <pre><code>  private void sendEmail(Email invite) {
              MailMessage mail = new MailMessage();
              SmtpClient SmtpServer = new SmtpClient(smtpServerName);
              mail.From = new MailAddress(emailUsername);
  
              mail.To.Add(invite.RecipientEmail);
              mail.Subject = invite.MessageSubject;
              mail.Body = invite.MessageBody;
  
              SmtpServer.UseDefaultCredentials = false;
              SmtpServer.Port = 587;
              SmtpServer.Credentials = new System.Net.NetworkCredential(emailUsername, emailPassword);
  //          SmtpServer.EnableSsl = true;
              SmtpServer.Send(mail);
          }  
  </code></pre>
  
  <p>Here's the error:  </p>
  
  <blockquote>
    <p>The SMTP server requires a secure connection or the client was not authenticated.  The server response was: SMTP authentication is required.</p>
  </blockquote>
  
  <p>Looking at other questions I tried what they suggested, to make <code>SmtpServer.EnableSsl = true</code>. This didn't work at all. It gave the following:</p>
  
  <blockquote>
    <p>System.Net.Mail.SmtpException: Server does not support secure connections.</p>
  </blockquote>
  
  <p>I'm guessing I should disable SSL and have it the way it was before.</p>
  
  <p>Any suggestions how to make email sending work again?</p>
  
  <p><strong>EDIT</strong><br>
  I've tried without <code>SmtpServer.UseDefaultCredentials = false;</code><br>
  I've tried with it set to true: <code>SmtpServer.UseDefaultCredentials =true;</code><br>
  I've tried commenting that line along with the following <code>//SmtpServer.Credentials = new System.Net.NetworkCredential(emailUsername, emailPassword);</code></p>