Ir al contenido principal

Test sending mail to your SMTP connector using Powershell


 8
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



>>telnet fic 26

220 FIC Microsoft ESMT
830 ready at Fri, 2 Dec 2005 09:24:56 +0000 MAIL Service, Version: 6.0.3790.1

>>HELO me.localdomain

250 FIC Hello [1.1.1.1]

>>MAIL FROM: example@example2.com

250 2.1.0 example@example2.com....Sender OK

>>RCPT TO: example2@example2.com

250 2.1.5 example2@example2.com

>>DATA

354 Start mail input; end with <CRLF>.<CRLF>

>>Just a test
>>.
>>

250 2.6.0 <FIClncFLoRne2043062b@FIC> Queued mail f
or delivery

>>quit

221 2.0.0 FIC Service closing transmission channel