December 9, 2002

Using SMTP Commands to Troubleshoot and Test SMTP Servers

Author: JT Smith

Before diving into specific software-configuration tips, here's a technique that can be used to troubleshoot or test any SMTP server: manual mail delivery. Normally, end users don't use SMTP commands because end users generally don't transfer their email manually. That's the job of MUAs, MDAs, and MTAs.

But it so happens that SMTP is a simple ASCII-based protocol built on TCP, and it's therefore possible to use SMTP commands to interact directly with an email server by telneting to TCP port 25 on that server. This is a useful technique for checking and troubleshooting MTA configurations. All you need is a telnet client and a working knowledge of a few of the commands in RFC 2821.

Here's an example session:

$ telnet 25 Trying Connected to Escape character is '^]'. 220 ESMTP Postfix helo 250 mail from:<> 250 Ok rcpt to:<> 250 Ok data 354 End data with <CR><LF>.<CR><LF> Subject: Test email from MickTesting, testing, 1-2-3.... 250 Ok: queued as F28B08603 quit 221 Bye Connection closed by foreign host.

Let's dissect the example, one command at a time:


The HELO command (SMTP commands are case insensitive) provides the remote server with your hostname or domain name.

mail from:<>

The MAIL command is used to specify your email's "from:" address. Again, this is usually taken at face value.

rcpt to:<>

Use the RCPT command to specify your email's "to:" address. This address may or may not be validated: a well-configured SMTP host will reject nonlocal destination addresses for incoming mail to prevent unauthorized mail relaying.


DATA means "and now, here's the message." To specify an optional Subject line, make the first word of the first line of your message "Subject:", followed immediately by your subject string. You can specify other SMTP headers too, each on its own line; if you want, you can even make headers up — e.g., "X-Slartibartfast:Whee!"

When your message is complete, type a period on an empty line, and press RETURN.


QUIT closes the SMTP session.

My own procedure to test any SMTP server I set up is first to deliver a message this way from the server to itself — i.e., telnetlocalhost25. If that succeeds, I then try the same thing from a remote system.

This technique doesn't work for advanced setups like SMTP over TLS (covered later in this chapter), but it's a fast, simple, and reliable test for basic SMTP server configurations, especially when you need to verify that antirelaying and other controls have been set correctly.

Click Here!