Test sending mail to your SMTP connector using Powershell


As a consultant I often test SMTP connectors on Exchange. 

There are several ways of doing this. There is the good old way of using telnet, ExchangePro has a great article describing the Telnet way of testing you SMTP connection:

The other way of testing if a SMTP connector works on Exchange (2007/2010), could be using PowerShell. In PowerShell 2.0 there is a builtin cmdlet cmdlet: Send-MailMessage

You can run the following command in PowerShell to do some mail testing:

Send-MailMessage –From sender@testserverdomain.com –To recipient@recipientdomain.com –Subject “Test Email” –Body “Test E-mail (body)” -SmtpServer smtpserver.fqdndomain.local

This only works for PowerShell V2, since the command is now builtin.

About Author

Peter is an Exchange specialist with over 15+ years of experience with Exchange Server and certified Microsoft Certified Master (MCM) and Microsoft Certified Solutions Master (MCSM) on Exchange Server. He has been awarded the Microsoft MVP award, every year since 2007. He is active in the Microsoft community and User Group Leader for CoLabora (a danish UC & Cloud User Group). He works as an Cloud & Infrastructure Architect and Consulent, with primary focus on Exchange, Office 365, Azure and Skype for Business.


  1. The downside to Send-MailMessage is there is no output/feedback. With Telnet, you see all SMTP responses step by step.

    For instance, if you want to test if a sender or domain is accepted at the gateway.

    • $SMTPSvr = ‘smtpserver.fqdndomain.local’
      $from = ‘sender@testserverdomain.com’
      $to = ‘recipient@recipientdomain.com’
      #testing connection to server:
      Test-NetConnection $SMTPSvr -port 25​

      Send-MailMessage –From $from –To $to –Subject “Test Email” –Body “Test E-mail (body)” -SmtpServer $SMTPSvr

  2. Fantastic! Their SMTP Relay Exchange Connector accepted some users but not a mailing list.

    PS D:\> Send-MailMessage -from user@company.local -to user@company.local -subject “test Powershell” -Body
    “Test Powersehll conenction to Exchange Connector” -smtpserver
    PS D:\> Send-MailMessage -from user@company.local -to list@company.local -subject “test Powershell
    ” -Body “Test Powersehll conenction to Exchange Connector” -smtpserver
    Send-MailMessage : Mailbox unavailable. The server response was: 5.1.1 User unknown
    At line:1 char:17
    + Send-MailMessage <<<

    • Hi
      You need to make sure, the Connector you are creating, is communicating on Port 25000. Have you gone through the steps (from your link):
      Configure send Connector with proper destination SMTP port.
      1. Go to EMS from Exchange server 2010.
      2. From Shell type below command and press enter.
      Note choose the
      Get-SendConnector -identity Connector_to_SAP |Set-SendConnector -port 2500

Copyright 2005-2015 - Peter Schmidt.