Misc. Scripting Windows Server
Matt Hansen  

Powershell Script to Test SMTP

Reading Time: < 1 minute

This one is going to be short and sweet, I’ve been testing SMTP with and without encryption and wanted a good script for that.

Here are the lines that you’ll want to look at configuring:

  • Line 5: “$smtpServer =”InsertYourSmtpServerHere”
  • Line 12: Change the $false value to $true if you want to encrypt your SMTP with SSL
  • Line 13: If you’re using a non-default SMTP port, change the “25” to whatever you’re using
  • Line 15: Only change this if you need to enter credentials for authentication
  • Line 18/19: Change these to who you want to say the email is from, and to whom it is being delivered.
  • Line 21: Change this to whatever you want your email title to be
  • Line 25: Change this to say whatever you want the body of the email to say


There are also some write-host’s in there to let you know the values that are being run and whether or not they were successful, which will print to the powershell console.






2 thoughts on “Powershell Script to Test SMTP

  1. Deepak

    I need a simple script that will telnet 2 IP address in port 25 from my one of the exchange server.

    1. mshansen01

      Quick google search looks like there are a few written out there already, such as this – http://www.travisgan.com/2014/03/use-powershell-to-test-port.html

Leave a Reply to DeepakCancel reply

%d bloggers like this: