title: Send-MailMessage - Unable to connect to the remote server
body: <p>I work on a server on Windows Server 2016.
  My aim is to send a mail using PowerShell, I wrote the script below.</p>
  
  <pre><code>Send-MailMessage -From "john.doe@mydomaine.com" -To "john.doe@mydomaine.com" -Subject "votre objet" -SmtpServer "smtp.office365.com" -Body "Blablabla" -Credential "john.doe@mydomaine.com" -Port "587" -UseSsl
  </code></pre>
  
  <p>This script works fine when I execute it on my PC, the mail is sent. So my script is OK.</p>
  
  <p>When I execute it on the server I have this error "Unable to connect to the remote server". When I ping the smtp.office365.com, it is OK.</p>
  
  <p>Does anyone have a idea about what is the problem?</p>
  
  <p>Here the complete error:</p>
  
  <pre>
  Send-MailMessage : Impossible de se connecter au serveur distant
  Au caractère Ligne:1 : 1
  + Send-MailMessage -From "john.doe@mydomaine.com" -To "john.doe@myd ...
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidOperation : (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException
      + FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage
  </pre>