title: "The remote certificate is invalid according to the validation procedure" when sending emails from a azure app
body: <p>We have two Azure apps that run an MVC website in one and a continuous webjob in the other. Both suddenly yesterday around midday started giving the error below when sending emails using smtpclient.</p>
  
  <blockquote>
    <p>The remote certificate is invalid according to the validation procedure</p>
  </blockquote>
  
  <p>No changes have been made in the code or in the mail server. We had this issue in February 2017 with no solution then (<a href="https://social.msdn.microsoft.com/Forums/en-US/f2f35ab9-3d0a-490f-b639-8ea5abda92d5/intermittent-the-remote-certificate-is-invalid-according-to-the-validation-procedure?forum=windowsazurewebsitespreview" rel="nofollow noreferrer">https://social.msdn.microsoft.com/Forums/en-US/f2f35ab9-3d0a-490f-b639-8ea5abda92d5/intermittent-the-remote-certificate-is-invalid-according-to-the-validation-procedure?forum=windowsazurewebsitespreview</a>) and again the same issue around September 2016.</p>
  
  <p>Same code sends the email fine locally and it also works from one of our VMs. </p>
  
  <pre><code>using (var smtp = new SmtpClient("mail.server.com", 25))
  {
      smtp.EnableSsl = true;
      smtp.Credentials = new NetworkCredential(username, password);
      smtp.Send(message);
  }
  </code></pre>
  
  <p>Tried <a href="https://twitter.com/AzureSupport" rel="nofollow noreferrer">https://twitter.com/AzureSupport</a> but they are not replying. We don't have Azure support plan but why would we have to pay for something we didn't break or wait 8 hours or even an 1 hour for such critical part of any business like sending an email?</p>
  
  <p>We've started rolling most of our web apps to Azure but we've been moving them back to a server since it's one problem after another... Those two Azure apps were the last ones and now only one left and only because it uses webjobs and the code relies on being a webjob.</p>
  
  <p>UPDATE:
  Both certificates thumbprints in Azure app and mail server match.</p>