How to Send a Test Email Through Windows PowerShell



Description of Issue

How can I test whether or not my SMTP server is failing to send emails?



Context
  • Test email

  • SMTP 

  • PowerShell



Cause

Windows PowerShell has a cmdlet called Send-MailMessage which can be used to test sending emails from the server for diagnosing SMTP issues.



Resolution
  1. From the Application server, run Windows PowerShell as administrator

  2. Using the script for the applicable port, replace recipient_email_address, sender_email_address, and smtp_servername_or_ip with the applicable information.  

    1. Port 25:

      1. Send-MailMessage -To recipient_email_address -From sender_email_address -Subject "Test Email" -Body "Test SMTP Service from PowerShell on Port 25" -SmtpServer smtp_servername_or_ip -Port 25

    2. Port 587:

      1. Send-MailMessage -To recipient_email_address -From sender_email_address -Subject "Test Email" -Body "Test SMTP Service from PowerShell on Port 587" -SmtpServer smtp_servername_or_ip -Credential (Get-Credential) -UseSsl -Port 587

      2. You will be prompted to enter a login user id and password for the SMTP server

  3. Send-MailMessage will give detailed error messages should emails fail to send



Additional Information

If testing Munis emails, the SMTP information can be found in Munis under System Administration > General Administration > System Settings > click the Email tab

How To Send Test Email Through Munis

How to Send a Test Email Through SQL Server Management Studio