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 [email protected] –To [email protected] –Subject “Test Email” –Body “Test E-mail (body)” -SmtpServer smtpserver.fqdndomain.local

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

8 thoughts on “Test sending mail to your SMTP connector using Powershell”

  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 = ‘[email protected]
      $to = ‘[email protected]
      #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 [email protected] -to [email protected] -subject “test Powershell” -Body
    “Test Powersehll conenction to Exchange Connector” -smtpserver 10.11.12.13
    PS D:\> Send-MailMessage -from [email protected] -to [email protected] -subject “test Powershell
    ” -Body “Test Powersehll conenction to Exchange Connector” -smtpserver 10.11.12.13
    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

Comments are closed.