Test the Office365 SMTP Relay Service from PowerShell

Spread the love

Trying to test the Office365 SMTP Relay Service to troubleshoot an issue I had with email sending today I came across this little useful command in PowerShell. All I had to do is enter the credentials and then send a test email.

  1. To open PowerShell right-click the start button and Choose Windows PowerShell.

  2. Enter the following command
    $msolcred = get-credential
  3. A window pops up. Enter your office365 credentials there.

  4. Then use the Send-MailMessage command to send a test email
    Send-MailMessage –From georgia.k@c***i.gr –To georgia.k@c***i.gr –Subject “Guess what!” –Body “I am Testing the SMTP Relay Service from PowerShell” -SmtpServer smtp.office365.com -Credential $msolcred -UseSsl -Port 587

  5. If there is no error check your inbox for a new email!

    If there are any connectivity or other issues, you can see the error and troubleshoot accordingly.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *