Saturday, August 19, 2017

How to use Power-Shell to Perform SMTP Relay Test

In most cases, when application owner claiming, e-mails aren’t relayed through the existing internal application relay front end, you will need to perform few basic troubleshooting steps. Bear in mind asking basic questions up front will make your job easier.

What is the IP address of your application?
What platform your application is running from? (In this scenario we will assume the application is installed
on Windows Serer.

What is the host name ( FQDN) or IP address your application is configured to relay through
Do you have any logs on your application showing SMTP handshake (you are asking TCP/IP handshake).
Most   cases you won’t get this detailed information

If telnet service is installed you can sent e-mail from command line and observe the response. If SMTP relay
Front end accepting e-mails, you will need to figure it out what is happening on the transport and delivery

Here is simple PS code can be used to simplify the test from Application Server. You will need to change few variables to make this cod work in your environment

$smtpServer = ""
$smtpFrom   = " "
$smtpTo     = " "


$subject    = "Testing SMTP Relay"
$body       = "smtp relay testing"
$smtpServer = ""
$smtpFrom   = " "
$smtpTo     = " "

$Computer = $env:computername
$message  = " sent from "

#()Subject body
$messageSubject = $subject
$messageBody = $body + $message + $Computer

$smtp = New-Object Net.Mail.SmtpClient($smtpServer)

Oz Casey, Dedeal
Systems Engineer (Blog) (Blog) (Twitter)