SMTP Command Line - Testing

Introduction to Exchange Server 2003 SMTP Raw Commands

 

This page explains the raw SMTP commands that you can execute to troubleshoot email on an Microsoft Exchange 2003 server.  Instead of sending email from Outlook, we will create a telnet shell and then type these SMTP commands, ehlo, Mail from: rcpt to: and data.

 

Launch telnet from a cmd prompt

 

Let us begin troubleshooting with an easy command.  Suppose we wish to test that the SMTP service is running on an Exchange 2003 server.  What we need is a telnet shell, so let us launch a cmd box and then type: Telnet server 25.  Naturally, follow through by pressing the Enter key for the carriage return.

 

 

Telnet server 25
 

 

Learning Points

 

  • Telnet is a command to open up a shell.
  • For 'server' substitute the name of your Exchange 2003 computer.  My server is called Alan.
  • 25 is the port number for SMTP  (Telnet itself uses port 23).

 

This is what you should see in the cmd box:

 

 

220 MAIL.ASUPPORT.com Microsoft ESMTP MAIL Service, ......

 

 

Learning Points

 

  • 220 - This return code (220) indicates success.
  • 2yz - Means the SMTP command completed OK.
  • x2z - Means connected.
  • MAIL.ASUPPORT.com  - Is the fully qualified name of the server.
  • Microsoft ESMTP MAIL Service - Tells you this mail server understands Extended SMTP.

 

Type in one word: ehlo  

 

This is what should what you should see when you type ehlo.  (Remember to follow up ehlo by pressing the Enter key.)

 

 

220 MAIL.ASUPPORT.com Microsoft ESMTP MAIL Service,

ehlo

250 MAIL.ASUPPORT.com Hello [10.10.1.1]

250-TURN

250-SIZE

250-ETRN

250-PIPELINING

250-DSN

250-ENHANCEDSTATUSCODES

250-8bitmime

250-BINARYMIME

250-CHUNKING

250-VRFY

250-X-EXPS GSSAPI NTLM LOGIN

250-X-EXPS=LOGIN

250-AUTH GSSAPI NTLM LOGIN

250-AUTH=LOGIN

250-X-LINK2STATE

250-XEXCH50

250 OK

 

 

SMTP Learning Points for Raw Commands

 

  • ESMTP uses ehlo as a greeting.  It's just a way of establishing an initial connection.
  • SMTP uses helo instead of ehlo, this is the older form of the SMTP language.
  • 250 - Means the action which you requested, completed OK.  (Remember codes beginning with 2yz indicate success.

 

Sending email

 

Let us finish as we started, by paying attention to detail.  Here are 3 vital SMTP commands to master when you troubleshoot,

mail from:

rcpt to:

data

 

Note the colon after both from: and to:.  Also after you type the data, in this example, 'Where are you server?', remember to type a full stop '.' or period as some call this key stroke.  Please note that the last but one line is not empty, can you see a '.' representing a full stop?

 

 

220 MAIL.ASUPPORT.com Microsoft ESMTP MAIL Service

ehlo

250 MAIL.ASUPPORT.com Hello [10.10.1.1]

More verbs....

250 OK

mail from: guyt@exchguy.com

250 2.1.0 guyt@exchguy.com....Sender OK

rcpt to: administrator@asupport.com

250 2.1.5 administrator@asupport.com

data

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

Where are you server?

.

250 2.6.0 <AlanUNPPqlY2LukY4W00000001@Alan.ExchGuy.com> Queued mail for delivery

 

Learning Points

 

  • Note the colon: after mail from: and rcpt to:.
  • Once you type data, examine the server's response:
    354 Start mail input, end with <CRLF>.<CRLF>.  SMTP tells you to end with 2 carriage returns with a full stop in between.
  • I confess.  I have an aversion to 'Test', so chose 'Where are you server?' as the data.
  • Unlike cmd, with SMTP commands you cannot use doskey. (The arrow keys just do not work.)
  • Don't be put off by lots of 5yz error messages, just try again.
  • When you have finished your SMTP / Telnet session type quit twice, once to end the SMTP session and then once again to end telnet.

 

Troubleshooting Ideas

 

Now that you have mastered the SMTP command basics, here are ideas for how and why you would use these raw SMTP commands.  For instance, raw SMTP commands are useful to troubleshoot relaying.  If you try to send an email to recipient address outside your organization, then the reply will tell you whether or not that email is relayed.  For example, the response maybe: 550 5.7.1  Unable to relay.  Whereas if you can relay, then you would get the response of,  250 2.1.5.

If you're trying to solve the cause of NDRs, try emailing users at different Exchange 2003 servers, the raw command would be similar to,  rcpt to: diffuser@ somewherelse.net

 

SMTP error codes

 

As I hinted at the beginning, I found this raw SMTP technique difficult and had my fair share of these error codes.  Most of my troubleshooting problems began with 5yz indicating a fatal error with that SMTP command.

 

421 - <service not available, closing channel> (domain)

451 - <req. action aborted: local error in processing>

452 - <req. action not taken: insufficient system storage>

500 - <syntax error, command unrecognized>

501 - <syntax error in arguments> ()

502 - <command not implemented>

550 - <req. action not taken: mailbox unavailable>

551 - <user not local; please try <forward-path>>

552 - <req. mail action aborted: exceeded storage allocation>

554 - <transaction failed>