December 23, 2014

Check SMTP address validity with only command prompt

Recently I had an interview question that was not Exchange or Powershell based. This is an important thing for every exchange admin to know as this is something that can be done quickly and on the fly.

The question:
If you were on a Windows box and you only had access to command prompt. How would you check if an smtp address was valid on an exchange system?

Dont forget:
You can't use Powershell
You can't use the Exchange GUI

This is a telnet question.

As we all know telnet is a part of an exchange admins role when checking whether servers are talking to each other.

Start with the communication with the server, then try to send an email.

You can start a Telnet session by using the Telnet command in the following format:

Note Press ENTER after you type each line. 

telnet servername portnumber

For example, type: 
telnet mail.domain.com 25


NB: You can replace servername with the IP address or the FQDN of the SMTP server that you want to connect to. 

If the command works, you receive a response from the SMTP server that is similar to the following: 
220 site.domain.com Microsoft Exchange Internet Mail Connector <version number of the IMC>

Start communication by typing the following command: 
EHLO test.com

If the command is successful, you receive the following response: 

250 OK

Type the following command to tell the receiving SMTP server who the message is from: 
MAIL FROM:Admin@domain.com

Note This address can be any SMTP address that you want, but it is a good idea to use a valid e-mail address possibly your own for testing. Using a non-valid smtp address will result in an NDR (non-delivery receipt).

If you do not use a valid e-mail address when you send a message, you cannot determine if the message had a delivery problem, because the non-delivery report (NDR) cannot reach an IP address that is not valid. If you use a valid e-mail address, you receive the following response from the SMTP server: 
250 OK - MAIL FROM Admin@domain.com

Type the following command with the SMTP address of the person you want to send to: 

RCPT TO: User@Domain.Com

You receive the following response: 
250 OK - Recipient User@ Domain.Com

Type the following command to tell the SMTP server that you are ready to send data: 
DATA

You receive the following response: 
354 Send data. End with CRLF.CRLF

You are now ready to start typing the 822/2822 section of the message. The user will see this part of the message in their inbox. Type the following command to add a subject line: 
Subject: test message
Press ENTER two times. You do not receive a response from this command.

Note The two ENTER commands comply with Request for Comments (RFC) 822 and 2822. 822 commands must be followed by a blank line. 

Type the following command to add message body text: 
This is a test message.

Type a period (.) at the next blank line, and then press ENTER. You receive the following response: 
250 OK

Close the connection by typing the following command: 

QUIT

Summary: 

telnet mail.domain.com 25
helo domain.com
MAIL FROM:Admin@domain.com
RCPT TO: User@Domain.Com
Subject: test
DATA
Test test
.

QUIT



No comments:

Post a Comment