SMTP Commands and Response Codes
The first command that the Sender-SMTP client sends is either the HELO command or the EHLO command. EHLO is now the preferred command and is part of the basic service extensions. If an SMTP server does not support additional service extensions, it will respond with an error message indicating a syntax error.
This is the basic syntax for SMTP commands:
In this syntax, <CRLF> indicates that a carriage-return followed by a line-feed character is used to signal the end of the command line.
In the following commands, the term forward-path is a list of hosts the message travels through to reach its destination. The term reverse-path is used to indicate how to get back to the sender of the email, which can be helpful when returning error or other informational messages.
The basic SMTP commands include the following:
- HELO—This command (or the next one in this list) is sent by the Sender-SMTP client to the SMTP server to begin the mail transfer session. The argument to this command is the hostname of the Sender-SMTP computer.
- EHLO—This is now the preferred command that replaces the HELO command and indicates that the Sender-SMTP client wants to use SMTP extensions. This command also uses the Domain name instead of the IP address. If the SMTP server supports SMTP extensions, it returns a code of 250 to the client. If the server does not support the extensions, it returns a code of 500.
- AUTH—This stands for authenticate. The user provides a username/password to the SMTP server to authenticate the client before mail can be sent.
- ATRN—This stands for authenticated TURN. After a client has been authenticated to the SMTP server, this command instructs the Receiver-SMTP to return an OK response. In that case, the SMTP server must assume the function as the sender of the mail. Otherwise, the SMTP server can return a Bad Gateway message (reply number 502) and remain in the role as Receiver-SMTP
- DATA—This command is followed by actual data that makes up the email message. This includes both the body text and such things as the subject line.
- EXPN—Thisstands for expand. This command requests the SMTP server to tell the client whether the argument included with the command is a mailing list. If so, the server returns a list of the members of the mailing list to the client.
- HELP—Thiscommand instructs the SMTP server to return help information to the sender. The HELP command might or might not contain arguments.
- MAIL—This command includes the reverse path as its argument. This is the name of the sender, but it also can be a list of hosts that were used to relay the mail message from its original Sender-SMTP. In a list of hosts, the first host is the current Receiving-SMTP server. The last is the destination of the email.
- QUIT—The Sender-SMTP sends this command when it is finished. The server should return an OK message and then close down the transmission channel (that is, TCP connection).
- RCPT—This stands for recipient. The argument for this command is a single recipient, specified by using a forward-path list preceded by the letters TO:. If a mail message is being sent to more than one recipient, a separate RCPT command must be issued for every recipient.
- RSET—This aborts the current email transaction. The SMTP server should respond with an OK message.
- SAML—This stands for Send and Mail. Mail is the typical use today with SMTP. The send method is meant to be used when the SMTP server has been implemented to deliver mail directly to a recipient that is actively connected. The argument for this command, again, is a reverse-path showing the path to the destination of the email. The reverse-path text is preceded by the text FROM:.
- SEND—This command, not often implemented, specifies that the mail message be delivered directly to the destination, if it’s actively connected. If this cannot be done, the server returns a message code of 450 (the mailbox is not available). Similar to the SAML command, the argument for this command is the text FROM: followed by the reverse-path to the destination mailbox.
- SIZE—Thiscommand lets the Sender-SMTP inform the server of the size of the mail message it wants to send. This is supported only by SMTP implementations that use the SMTP Service Extensions. The server can return a message indicating that it cannot handle mail of the size requested, or it can accept the message.
- SOML—Thisstands for Send or Mail. Similar to SAML, this command requests that the mail be “sent” (for example, directly to the actively connected recipient) or mailed. The server tries the Send method first, and if that fails, the server attempts to deliver the message to the destination mailbox.
- TURN—Thiscommand instructs the Receiver-SMTP to assume the role of the sender of the mail (in which an OK response is returned). The server can refuse (with a code 502) and remain in the role of Receiver-SMTP.
- VRFY—This command asks the Receiver-SMTP to verify that the username that is passed as an argument with the command be checked to determine whether it’s valid. If the username is a valid one, the full name and mailbox of the user are returned.
Because SMTP allows for sending a single message to multiple recipients, a large mailing list could generate a lot of network traffic. Thus, the original SMTP RFC 821 recommends that only one copy of the actual email be sent to the server in this sort of situation. The SEND command (and its associated commands) was intended originally to send a message directly to a user’s terminal. In today’s world of PCs and workstations, it isn’t typical to find a user sitting at a terminal. It also usually is not desirable to have mail pop up suddenly on a user’s terminal if this function is still supported in your network. Instead, the MAIL command and its other associated commands are usually used.
The DATA portion of the mail message is terminated using the period (.) character by itself on a single line—which is followed by the line terminating characters (CRLF). Typically this will be <CRLF>.<CRLF>, because the first <CRLF> terminates the last line of actual data.
Possibly related posts: (automatically generated)
SMTP Commands and Response Codes
- How SMTP works
- Sender Authentication Systems
- The Post Office Protocol (POP3)
- Dedicated Server with Canadian Web Hosting
- The NIS Server ypserve Daemon and Maps Location Part 2
- What Is a Domain Tree? What Is a Forest?
- What Is a Domain Tree? What Is a Forest? continue...
- The Active Directory and Dynamic DNS continue...
- Installing Active Directory on a Windows Server 2003 Computer
- Primary, Secondary, and Caching-Only Name Servers
- May 25th

Some use domains to develop complete websites for many reasons, and others purchase domain names for parked domain traffic or simply for future resale value. … Cheap Domains
Gallery gives you an intuitive way to blend photo management seamlessly into your own website whether you’ re running a small personal site or a large community site. … Including NetObjects Fusion
When we make changes to your account or domain name for you, we often require the, the secret question and answer to your account as authorization. … Public WHOIS Database
This is how the website you create on your computer at home is transferred (uploaded) to the Internet. … Web Hosting