Skip to main content

3. The SMTP Procedures: Mail, Forwarding, Verifying and Expanding

This section presents the procedures used in SMTP in several parts. First comes the basic mail procedure defined as a mail transaction. Following this are descriptions of forwarding mail, verifying mailbox names and expanding mailing lists, sending to terminals instead of or in combination with mailboxes, and the opening and closing exchanges. At the end of this section are comments on relaying, and a note on mail domains. Throughout this section are examples of partial command and reply sequences, several complete scenarios are presented in Appendix F.

3.1. MAIL​

There are three steps to a SMTP mail transaction. The transaction is started with a MAIL command which gives the sender identification. A series of one or more RCPT commands follow giving the receiver information. Then a DATA command gives the mail data. And finally, the end of mail data indicator confirms the transaction.

The first step in the procedure is the MAIL command. The <reverse-path> contains the source mailbox.

MAIL <SP> FROM:<reverse-path> <CRLF>

This command tells the the SMTP-receiver that a new mail transaction is starting and to reset all its state tables and buffers including any recipients or mail data. It gives the reverse-path which can be used to report errors. If accepted, the receiver-SMTP returns a 250 OK reply.

The <reverse-path> can contain more than just a mailbox. The <reverse-path> is a reverse source routing list of hosts and source mailbox. The first host in the <reverse-path> should be the host sending this command.

The second step in the procedure is the RCPT command.

RCPT <SP> TO:<forward-path> <CRLF>

This command gives a forward-path identifying one recipient. If accepted, the receiver-SMTP returns a 250 OK reply, and stores the forward-path. If the recipient is unknown the receiver-SMTP returns a 550 Failure reply. This second step of the procedure can be repeated any number of times.

The <forward-path> can contain more than just a mailbox. The <forward-path> is a source routing list of hosts and destination mailbox. The first host in the <forward-path> should be the host receiving this command.

The third step in the procedure is the DATA command.

DATA <CRLF>

If accepted, the receiver-SMTP returns a 354 Intermediate reply and considers all succeeding lines to be the message text. When the end of text is received and stored the SMTP-receiver sends a 250 OK reply.

Since the mail data is sent on the transmission channel the end of the mail data must be indicated so that the command and reply dialog can be resumed. SMTP indicates the end of the mail data by sending a line containing only a period. A transparency procedure is used to prevent this interfering with the user's text (see Section 4.5.2).

Please note that the mail data includes the memo header items such as Date, Subject, To, Cc, From [2].

The end of mail data indicator also confirms the mail transaction and tells the receiver-SMTP to now process the stored recipients and mail data. If accepted, the receiver-SMTP returns a 250 OK reply. The DATA command should fail only if the mail transaction was incomplete (for example, no recipients), or if resources are not available.

The above procedure is an example of a SMTP mail transaction. These commands must be used only in the order discussed above. Example 1 (below) illustrates the use of these commands in a mail transaction.

-------------------------------------------------------------

Example of the SMTP Procedure

This SMTP example shows mail sent by Smith at host Alpha, to
Jones, Green, and Brown at host Beta. Here we assume that host
Alpha contacts host Beta directly.

S: MAIL FROM:<Smith@Alpha>
R: 250 OK

S: RCPT TO:<Jones@Beta>
R: 250 OK

S: RCPT TO:<Green@Beta>
R: 550 No such user here

S: RCPT TO:<Brown@Beta>
R: 250 OK

S: DATA
R: 354 Start mail input; end with <CRLF>.<CRLF>
S: Blah blah blah...
S: ...etc. etc. etc.
S: <CRLF>.<CRLF>
R: 250 OK

The mail has now been accepted for Jones and Brown. Green did
not have a mailbox at host Beta.

Example 1

-------------------------------------------------------------

3.2. FORWARDING​

There are some cases where the destination information in the <forward-path> is incorrect, but the receiver-SMTP knows the correct destination. In such cases, one the following replies should be used to allow the sender to contact the correct destination.

251 User not local; will forward to <forward-path>

This reply indicates that the receiver-SMTP knows the user's mailbox is on another host and indicates the correct forward-path to use in the future. Note that either the host or user or both may be different. The receiver takes responsibility for delivering the message.

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

This reply indicates that the receiver-SMTP knows the user's mailbox is on another host and indicates the correct forward-path to use. Note that either the host or user or both may be different. The receiver refuses to accept mail for this user, and the sender must either redirect the mail according to the information provided or return an error response to the originating user.

Example 2 illustrates the use of these responses.

-------------------------------------------------------------

Example of Forwarding

Either

S: RCPT TO:<Postel@ISI>
R: 251 User not local; will forward to <Postel@ISIF>

Or

S: RCPT TO:<Paul@ISIB>
R: 551 User not local; please try <Mockapetris@ISIF>

Example 2

-------------------------------------------------------------

3.3. VERIFYING AND EXPANDING​

SMTP provides as additional features, commands to verify a user name or expand a mailing list. This is done with the VRFY and EXPN commands, which have a character string arguments. For the VRFY command, the string is a user name, and the the response may include the full name of the user and must include the mailbox of the user. For the EXPN command, the string identifies a mailing list, and the multiline response may include the full name of the users and must give the mailboxes on the mailing list.

The case of verifying a user name is straightforward as shown in example 3.

-------------------------------------------------------------

Example of Verifying a User Name

Either

S: VRFY Postel
R: 250 Jon Postel <Postel@ISIF>

Or

S: VRFY Jones
R: 550 String does not match anything.

Example 3

-------------------------------------------------------------

The case of expanding a mailbox list requires a multiline reply as shown in example 4.

-------------------------------------------------------------

Example of Expanding a Mailing List

Either

S: EXPN Example-People
R: 250-Jon Postel <Postel@ISIF>
R: 250-Fred Fonebone <Fonebone@ISIQ>
R: 250-Sam Q. Smith <SQSmith@ISIQ>
R: 250-Quincy Smith <@ISIF,Q-Smith@ISI-VAXA>
R: 250-<joe@foo-unix>
R: 250 <xyz@bar-unix>

Or

S: EXPN Executive-Washroom-List
R: 550 Access Denied to You.

Example 4

-------------------------------------------------------------

The character string arguments of the VRFY and EXPN commands cannot be further restricted due to the variety of implementations of the user name and mailbox list concepts. On some systems it may be appropriate for the argument of the EXPN command to be a file name for a file containing a mailing list, but again there is a variety of file naming conventions in the internet.

The VRFY and EXPN commands are not included in the minimum implementation (Section 4.5.1), and are not required to work across relays when they are implemented.