Академический Документы
Профессиональный Документы
Культура Документы
]- RFC 821
Standard 10
TABLE OF CONTENTS
1. INTRODUCTION .................................................. 1
2. THE SMTP MODEL ................................................ 2
3. THE SMTP PROCEDURE ............................................ 4
3.1. Mail ..................................................... 4
3.2. Forwarding ............................................... 7
3.3. Verifying and Expanding .................................. 8
3.4. Sending and Mailing ..................................... 11
3.5. Opening and Closing ..................................... 13
3.6. Relaying ................................................ 14
3.7. Domains ................................................. 17
3.8. Changing Roles .......................................... 18
4. THE SMTP SPECIFICATIONS ...................................... 19
4.1. SMTP Commands ........................................... 19
4.1.1. Command Semantics ..................................... 19
4.1.2. Command Syntax ........................................ 27
4.2. SMTP Replies ............................................ 34
4.2.1. Reply Codes by Function Group ......................... 35
4.2.2. Reply Codes in Numeric Order .......................... 36
4.3. Sequencing of Commands and Replies ...................... 37
4.4. State Diagrams .......................................... 39
4.5. Details ................................................. 41
4.5.1. Minimum Implementation ................................ 41
4.5.2. Transparency .......................................... 41
4.5.3. Sizes ................................................. 42
APPENDIX A: TCP ................................................. 44
APPENDIX B: NCP ................................................. 45
APPENDIX C: NITS ................................................ 46
APPENDIX D: X.25 ................................................ 47
APPENDIX E: Theory of Reply Codes ............................... 48
APPENDIX F: Scenarios ........................................... 51
GLOSSARY ......................................................... 64
REFERENCES ....................................................... 67
1. INTRODUCTION
The objective of Simple Mail Transfer Protocol (SMTP) is to transfer mail reliably
and efficiently.
The SMTP design is based on the following model of communication: as the result of
a user mail request, the sender-SMTP establishes a two-way transmission channel to a
receiver-SMTP. The receiver-SMTP may be either the ultimate destination or an
intermediate. SMTP commands are generated by the sender-SMTP and sent to the receiver-
SMTP. SMTP replies are sent from the receiver-SMTP to the sender-SMTP in response to
the commands.
Once the transmission channel is established, the SMTP-sender sends a MAIL command
indicating the sender of the mail. If the SMTP-receiver can accept mail it responds
with an OK reply. The SMTP-sender then sends a RCPT command identifying a recipient of
the mail. If the SMTP-receiver can accept mail for that recipient it responds with an
OK reply; if not, it responds with a reply rejecting that recipient (but not the whole
mail transaction). The SMTP-sender and SMTP-receiver may negotiate several recipients.
When the recipients have been negotiated the SMTP-sender sends the mail data,
terminating with a special sequence. If the SMTP-receiver successfully processes the
mail data it responds with an OK reply. The dialog is purposely lock-step, one-at-a-
time.
+----------+ +----------+
+------+ | | | |
| User |<-->| | SMTP | |
+------+ | Sender- |Commands/Replies| Receiver-|
+------+ | SMTP |<-------------->| SMTP | +------+
| File |<-->| | and Mail | |<-->| File |
|System| | | | | |System|
+------+ +----------+ +----------+ +------+
Sender-SMTP Receiver-SMTP (storage-mailbox)
(client) (server)
Figure 1- Model for SMTP Use
The SMTP provides mechanisms for the transmission of mail; directly from the
sending user's host to the receiving user's host when the two host are connected to
the same transport service, or via one or more relay SMTP-servers when the source and
destination hosts are not connected to the same transport service.
To be able to provide the relay capability the SMTP-server must be supplied with
the name of the ultimate destination host as well as the destination mailbox name.
The argument to the MAIL command is a reverse-path, which specifies who the mail is
from. The argument to the RCPT command is a forward-path, which specifies who the mail
is to. The forward-path is a source route, while the reverse-path is a return route
(which may be used to return a message to the sender when an error occurs with a
relayed message).
In case of multiple recipients the SMTP sends only one copy of the data for all the
recipients at the same destination host. Commands and replies are not case sensitive.
When the transport service provides an 8-bit byte (octet) transmission channel, each
7-bit character is transmitted right justified in an octet with the high order bit
cleared to zero.
3.1. MAIL
There are three steps to SMTP mail transactions. The transaction is started with
a MAIL command which gives the sender identification. A series of one or more RCPT
commands follows giving the receiver information. Then a DATA command gives the mail
data. And finally, the end of mail data indicator confirms the transaction.
MAIL <SP> FROM:<reverse-path> <CRLF> //(<SP> - space , <CRLF> - enter)
This command tells the SMTP-receiver(client) 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 second step in the procedure is the RCPT command.
DATA <CRLF>
SMTP indicates the end of the mail data by sending a line containing only a
period. 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.
Example of the SMTP Procedure (time shared mainframes)
This SMTP example shows mail sent by Smith at host Alpha.ARPA (smith is directly
connected to host alpha.ARPA)
the , to Jones, Green, and Brown at host Beta.ARPA. Here we
assume that host Alpha contacts host Beta directly.
[Smith activates MUA, and make TCP connection to Beta.ARPA at port 25.
R: 220 Beta.ARPA // Reply from remote SMTP server
S: HELLO Alpha.ARPA // Sender sends
R: 250 Hello Alpha.ARPA , pleased to meet you
S: MAIL FROM:<Smith@Alpha.ARPA>
R: 250 sender OK
S: RCPT TO:<Jones@Beta.ARPA>
R: 250 recipient OK
S: RCPT TO:<Green@Beta.ARPA>
R: 550 No such user here
S: RCPT TO:<Brown@Beta.ARPA>
R: 250 recipient 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.
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 of
the following replies should be used to allow the sender to contact the correct
destination.
This reply indicates that the receiver-SMTP knows the user's mailbox is on
another host and indicates the correct forward-path to use.
Example of Forwarding
Either
S: RCPT TO:<Postel@USC-ISI.ARPA>
R: 251 User not local; will forward to <Postel@USC-ISIF.ARPA>
Or
S: RCPT TO:<Paul@USC-ISIB.ARPA>
R: 551 User not local; please try <Mockapetris@USC-ISIF.ARPA>
If a host implements the VRFY or EXPN commands then at least local mailboxes
must be recognized as "user names". If a host chooses to recognize other strings as
"user names" that is allowed.
If a request is made to verify a mailing list a positive response can be given
if on receipt of a message so addressed it will be delivered to everyone on the list,
otherwise an error should be reported (e.g., "550 That is a mailing list, not a
user"). If a request is made to expand a user name a positive response can be formed by returning a list
containing one name, or an error can be reported (e.g., "550 That is a user name, not a mailing list").
Example of Verifying a User Name
Either
S: VRFY Smith
R: 250 Fred Smith <Smith@USC-ISIF.ARPA>
Or
S: VRFY Smith
R: 251 User not local; will forward to <Smith@USC-ISIQ.ARPA>
Or
S: VRFY Jones
R: 550 String does not match anything.
Or
S: VRFY Jones
R: 551 User not local; please try <Jones@USC-ISIQ.ARPA>
Or
S: VRFY Gourzenkyinplatz
R: 553 User ambiguous.
The case of expanding a mailbox list requires a multiline reply as shown
The Send Or MaiL command requires that the mail data be delivered to the
user's terminal if the user is active (and accepting terminal messages) on the host.
If the user is not active (or not accepting terminal messages) then the mail data is
entered into the user's mailbox. The mail transaction is successful if the message is
delivered either to the terminal or the mailbox.
The Send And MaiL command requires that the mail data be delivered to the
user's terminal if the user is active (and accepting terminal messages) on the host.
In any case the mail data is entered into the user's mailbox. The mail transaction is
successful if the message is delivered the mailbox.
The same reply codes that are used for the MAIL commands are used for these
commands.
3.5. OPENING AND CLOSING
The following two commands are used in transmission channel opening and closing:
3.6. RELAYING
If when the message arrives at an SMTP (server- a relay) the first element of the
forward-path is not the identifier of that SMTP the element is not deleted from
the forward-path and is used to determine the next SMTP to send the message to. In any
case, the SMTP adds its own identifier to the reverse-path.
Using source routing the receiver-SMTP receives mail to be relayed to another
server-SMTP. The receiver-SMTP transforms the command arguments by (re)moving its own
identifier from the forward-path to the beginning of the reverse-path. The receiver-
SMTP then becomes a sender-SMTP, establishes a transmission channel to the next SMTP
in the forward-path, and sends it the mail.
The first host in the reverse-path should be the host sending the SMTP commands,
and the first host in the forward-path should be the host receiving the SMTP commands.
Notice that the forward-path and reverse-path appear in the SMTP commands and
replies, but not necessarily in the message. That is, there is no need for these
paths and especially this syntax to appear in the "To:" , "From:", "CC:", etc. fields
of the message header.
If a server-SMTP has accepted the task of relaying the mail and later finds that
the forward-path is incorrect or that the mail cannot be delivered for whatever
reason, then it must construct an "undeliverable mail" notification message and send
it to the originator of the undeliverable mail (as indicated by the reverse-path).
This notification message must be from the server-SMTP at this host. Of course,
server-SMTPs (intermediate servers) should not send notification messages about problems
with notification messages (back to originator of this message). One way to prevent loops in
error reporting is to specify a null reverse-path in the MAIL command of a
notification message. When such a message is relayed it is permissible to leave the
reverse-path null. A MAIL command with a null reverse-path appears as follows:
MAIL FROM:<>
S: MAIL FROM:<>
R: 250 ok
S: RCPT TO:<@HOSTX.ARPA:JOE@HOSTW.ARPA> //(reverse path list)
R: 250 ok
S: DATA
R: 354 send the mail data, end with .
S: Date: 23 Oct 81 11:22:33
S: From: SMTP@HOSTY.ARPA
S: To: JOE@HOSTW.ARPA
S: Subject: Mail System Problem
S:
S: Sorry JOE, your message to SAM@HOSTZ.ARPA lost.
S: HOSTZ.ARPA said this:
S: "550 No Such User"
S: .
R: 250 ok
The TURN command may be used to reverse the roles of the two programs (SMTP server
and client)
communicating over the transmission channel.If program-A is currently the
sender-SMTP and it sends the TURN command and receives an ok reply (250) then program-
A becomes the receiver-SMTP. To refuse to change roles the receiver sends the 502
reply.
The SMTP commands define the mail transfer or the mail system function
requested by the user. SMTP commands are character strings terminated by <CRLF>. The
command codes themselves are alphabetic characters terminated by <SP> if parameters
follow and <CRLF> otherwise. The syntax of mailboxes must conform to receiver site
conventions. The SMTP commands are discussed below.
A mail transaction involves several data objects which are communicated as
arguments to different commands. The reverse-path is the argument of the MAIL command,
the forward-path is the argument of the RCPT command, and the mail data is the
argument of the DATA command.
HELLO (HELO)
This command is used to initiate a mail transaction in which the mail data
is delivered to one or more mailboxes. The argument field contains a reverse-path. The
reverse-path consists of an optional list of hosts and the sender mailbox. When the
list of hosts is present, it is a "reverse" source route and indicates that the mail
was relayed through each host on the list (the first host in the list was the most
recent relay). This list is used as a source route to return non-delivery notices to
the sender. As each relay host adds itself to the beginning of the list, it must use
its name as known in the IPCE to which it is relaying the mail rather than the IPCE
from which the mail came (if they are different). In some types of error reporting
messages (for example, undeliverable mail notifications) the reverse-path may be null.
DATA (DATA)
The receiver treats the lines following the command as mail data from the
sender. This command causes the mail data from this command to be appended to the mail
data buffer. The mail data may contain any of the 128 ASCII character codes. The mail
data is terminated by a line containing only a period, that is the character sequence
"<CRLF>.<CRLF>" .This is the end of mail data indication. The end of mail data
indication requires that the receiver must now process the stored mail transaction
information. This processing consumes the information in the reverse-path buffer, the
forward-path buffer, and the mail data buffer, and on the completion of this command
these buffers are cleared. If the processing is successful the receiver must send an
OK reply. If the processing fails completely the receiver must send a failure reply.
When the receiver-SMTP accepts a message either for relaying or for final
delivery it inserts at the beginning of the mail data a time stamp line. The time
stamp line indicates the identity of the host that sent the message, and the
identity of the host that received the message (and is inserting this time stamp),
and the date and time the message was received. Relayed messages will have multiple
time stamp lines. When the receiver-SMTP makes the "final delivery" of a message it
inserts at the beginning of the mail data a return path line. The return path line
preserves the information in the <reverse-path> from the MAIL command.
All undeliverable mail notification messages are sent using the MAIL command (even if
they result from processing a SEND, SOML, or SAML command).
Example of Return Path and Received Time Stamps
Return-Path: <@GHI.ARPA,@DEF.ARPA,@ABC.ARPA:JOE@ABC.ARPA>
Received: from GHI.ARPA by JKL.ARPA ; 27 Oct 81 15:27:39 PST
Received: from DEF.ARPA by GHI.ARPA ; 27 Oct 81 15:15:13 PST
Received: from ABC.ARPA by DEF.ARPA ; 27 Oct 81 15:01:59 PST
Date: 27 Oct 81 15:01:01 PST
From: JOE@ABC.ARPA
Subject: Improved Mailing System Installed
To: SAM@JKL.ARPA
SEND (SEND)
This command is used to initiate a mail transaction in which the mail data
is delivered to one or more terminals. The argument field contains a reverse-path.
This command is successful if the message is delivered to a terminal.
This command is used to initiate a mail transaction in which the mail data
is delivered to one or more terminals or mailboxes. For each recipient the mail data
is delivered to the recipient's terminal if the recipient is active on the host (and
accepting terminal messages), otherwise to the recipient's mailbox. The argument
field contains a reverse-path. This command is successful if the message is
delivered to a terminal or the mailbox.
This command is used to initiate a mail transaction in which the mail data
is delivered to one or more terminals and mailboxes. For each recipient the mail data
is delivered to the recipient's terminal if the recipient is active on the host (and
accepting terminal messages), and for all recipients to the recipient's mailbox. The
argument field contains a reverse-path. This command is successful if the message is
delivered to the mailbox.
RESET (RSET)
VERIFY (VRFY)
This command asks the receiver to confirm that the argument identifies a
user. If it is a user name, the full name of the user (if known) and the fully
specified mailbox are returned.
EXPAND (EXPN)
This command asks the receiver to confirm that the argument identifies a
mailing list, and if so, to return the membership of that list. The full name of the
users (if known) and the fully specified mailboxes are returned in a multiline reply.
HELP (HELP)
This command causes the receiver to send helpful information to the sender
of the HELP command. The command may take an argument (e.g., any command name) and
return more specific information as a response.
NOOP (NOOP)
QUIT (QUIT)
This command specifies that the receiver must send an OK reply, and then
close the transmission channel. The receiver should not close the transmission channel
until it receives and replies to a QUIT command (even if there was an error). The
sender should not close the transmission channel until it send a QUIT command and
receives the reply (even if there was an error response to a previous command). If the
connection is closed prematurely the receiver should act as if a RSET command had been
received (canceling any pending transaction, but not undoing any previously completed
transaction), the sender should act as if the command or transaction in progress had
received a temporary error (4xx).
TURN (TURN)
This command specifies that the receiver must either (1) send an OK reply
and then take on the role of thesender-SMTP, or (2) send a refusal reply and retain
the roleof the receiver-SMTP. To refuse to change roles the receiver sends the 502
reply. There are restrictions on the order in which these command may be used.
The first command in a session must be the HELO command. The HELO command
may be used later in a session as well. If the HELO command argument is not acceptable
a 501 failure reply must be returned and the receiver-SMTP must stay in
the same state. The NOOP, HELP, EXPN, and VRFY commands can be used at any time
during a session. The MAIL, SEND, SOML, or SAML commands begin a mail transaction.
Once started a mail transaction consists of one of the transaction beginning commands,
one or more RCPT commands, and a DATA command, in that order. A mail transaction may
be aborted by the RSET command. There may be zero or more transactions in a session.
Return-Path: <@CHARLIE.ARPA,@BAKER.ARPA:JOE@ABLE.ARPA>
Following are state diagrams for a simple-minded SMTP implementation. Only the
first digit of the reply codes is used. There is one state diagram for each group of
SMTP commands. The command groupings were determined by constructing a model for each
command and then collecting together the commands with structurally identical models.
For each command there are three possible outcomes: "success" (S), "failure"
(F), and "error" (E). In the state diagrams below we use the symbol B for "begin", and
the symbol W for "wait for reply".
1,2,3,4 and 5 reply code group.
First, the diagram that represents most of the SMTP commands:
1,3 +---+
----------->| E |
| +---+
|
+---+ cmd +---+ 2 +---+
| B |---------->| W |---------->| S |
+---+ +---+ +---+
|
| 4,5 +---+
----------->| F |
+---+
This diagram models the commands: HELO, MAIL, RCPT, RSET, SEND, SOML, SAML, VRFY,
EXPN, HELP, NOOP, QUIT, TURN.
4.5. DETAILS
4.5.1. MINIMUM IMPLEMENTATION
In order to make SMTP workable, the following minimum implementation is
required for all receivers: -- HELO, MAIL, RCPT, DATA, RSET, NOOP, QUIT
4.5.2. TRANSPARENCY
1. Before sending a line of mail text the sender-SMTP checks the first
character of the line. If it is a period, one additional period is inserted at the
beginning of the line.
4.5.3. SIZES
There are several objects that have required minimum maximum sizes. That is,
every implementation must be able to receive objects of at least these sizes, but
must not send objects larger than these sizes.
User - The maximum total length of a user name is 64 characters.
Domain- The maximum total length of a domain name or number is 64 characters.
command line- The maximum total length of a command line including the
command word and the <CRLF> is 512 characters.
reply line- The maximum total length of a reply line including the
reply code and the <CRLF> is 512 characters.
text line- The maximum total length of a text line including the <CRLF> is 1000
characters (but not counting the leading dot duplicated for transparency).
Errors due to exceeding these limits may be reported by using the reply codes,
for example:
500 Line too long.
501 Path too long
552 Too many recipients.
552 Too much mail data.
APPENDIX E
The third digit gives a finer gradation of meaning in each category specified
by the second digit. The list of replies illustrates this. Each reply text is
recommended rather than mandatory, and may even change according to the command with
which it is associated. On the other hand, the reply codes must strictly follow the
specifications in this section. Receiver implementations should not invent new codes
for slightly different situations from the ones described here, but rather adapt codes
already defined.
APPENDIX F
This SMTP example shows mail sent by Smith at host USC-ISIF, to Jones, Green,
and Brown at host BBN-UNIX. Here we assume that host USC-ISIF contacts host BBN-UNIX
directly. The mail is accepted for Jones and Brown. Green does not have a mailbox at
host BBN-UNIX.
S: RCPT TO:<@USC-ISIE.ARPA:Jones@BBN-VAX.ARPA>
R: 250 OK
S: DATA
R: 354 Start mail input; end with <CRLF>.<CRLF>
S: Date: 2 Nov 81 22:33:44
S: From: John Q. Public <JQP@MIT-AI.ARPA>
S: Subject: The Next Meeting of the Board
S: To: Jones@BBN-Vax.ARPA
S:
S: Bill:
S: The next meeting of the board of directors will be
S: on Tuesday.
S: John.
S: .
R: 250 OK
S: QUIT
R: 221 USC-ISIE.ARPA Service closing transmission channel
S: RCPT TO:<Admin.MRC@SU-SCORE.ARPA>
R: 250 OK
S: DATA
R: 354 Start mail input; end with <CRLF>.<CRLF>
S: Blah blah blah...
S: ...etc. etc. etc.
S: .
R: 250 OK
S: QUIT
R: 221 SU-SCORE.ARPA Service closing transmission channel
First the user's name is verified, then an attempt is made to send to the
user's terminal. When that fails, the messages is mailed to the user's mailbox.
R: 220 SU-SCORE.ARPA Simple Mail Transfer Service Ready
S: HELO MIT-MC.ARPA
R: 250 SU-SCORE.ARPA
S: VRFY Crispin
R: 250 Mark Crispin <Admin.MRC@SU-SCORE.ARPA>
S: SEND FROM:<EAK@MIT-MC.ARPA>
R: 250 OK
S: RCPT TO:<Admin.MRC@SU-SCORE.ARPA>
R: 450 User not active now
S: RSET
R: 250 OK
S: MAIL FROM:<EAK@MIT-MC.ARPA>
R: 250 OK
S: RCPT TO:<Admin.MRC@SU-SCORE.ARPA>
R: 250 OK
S: DATA
R: 354 Start mail input; end with <CRLF>.<CRLF>
S: Blah blah blah...
S: ...etc. etc. etc.
S: .
R: 250 OK
S: QUIT
R: 221 SU-SCORE.ARPA Service closing transmission channel
First each of two mailing lists are expanded in separate sessions with
different hosts. Then the message is sent to everyone that appeared on either list
(but no duplicates) via a relay host.
R: 250 OK
S: MAIL FROM:<Postel@USC-ISIF.ARPA>
R: 250 OK
S: RCPT TO:<eric@BERKELEY.ARPA>
R: 250
R: 220 BERKELEY.ARPA Simple Mail Transfer Service Ready
S: HELO USC-ISIF.ARPA
R: 250 BERKELEY.ARPA
S: MAIL FROM:<Postel@USC-ISIF.ARPA>
R: 250 OK
S: RCPT TO:<fabry@BERKELEY.ARPA>
R: 250 OK
S: RCPT TO:<eric@BERKELEY.ARPA>
R: 552 Recipient storage full, try again in another transaction
S: DATA
R: 354 Start mail input; end with <CRLF>.<CRLF>
S: Blah blah blah...
S: ...etc. etc. etc.
S: .OK
S: DATA
R: 354 Start mail input; end with <CRLF>.<CRLF>
S: Blah blah blah...
S: ...etc. etc. etc.
S: .
R: 250 OK
S: QUIT
R: 221 BERKELEY.ARPA Service closing transmission channel
host- A computer in the internetwork environment on which mailboxes or SMTP processes reside.
Mailbox -A character string (address) which identifies a user to whom mail is to be sent. Mailbox normally consists of the host and user
specifications. The standard mailbox naming convention is defined to be "user@domain". Additionally, the "container" in which mail is stored.
receiver-SMTP process- A process which transfers mail in cooperation with a sender-SMTP process. It waits for a connection to be
established via the transport service. It receives SMTP commands from the sender-SMTP, sends replies, and performs the specified operations.
sender-SMTP process- A process which transfers mail in cooperation with a receiver-SMTP process. A local language may be used in the user
interface command/reply dialogue. The sender-SMTP initiates the transport service connection. It initiates SMTP commands, receives replies,
and governs the transfer of mail.
session- The set of exchanges that occur while the transmission channel is open.
transaction- The set of exchanges required for one message to be transmitted for one or more recipients.
transmission channel- A full-duplex communication path between a sender-SMTP and a receiver-SMTP for the exchange of commands, replies, and
mail text.
user- A human being (or a process on behalf of a human being) wishing to obtain mail transfer service. In addition, a recipient of
computer mail.
=========================================================================
Network Working Group Craig Partridge
Request for Comments: 974 CSNET CIC BBN Laboratories Inc
January 1986
This RFC presents a description of how mail systems on the Internet are expected to
route messages based on information from the domain system described in RFCs 882, 883
and 973. Distribution of this memo is unlimited.
Introduction
The purpose of this memo is to explain how mailers are to decide how to route a
message addressed to a given Internet domain name. This involves a discussion of how
mailers interpret MX RRs, which are used for message routing. Note that this memo
makes no statement about how mailers are to deal with MB and MG RRs, which are used
for interpreting mailbox names.
Under RFC-882 and RFC-883 certain assumptions about mail addresses have been
changed. Up to now, one could usually assume that if a message was addressed to a
mailbox, for example, at LOKI.BBN.COM, that one could just open an SMTP connection to
LOKI.BBN.COM and pass the message along. This system broke down in certain situations,
such as for certain UUCP and CSNET hosts which were not directly attached to the
Internet, but these hosts could be handled as special cases in configuration files
(for example, most mailers were set up to automatically forward mail addressed to a
CSNET host to CSNET-RELAY.ARPA).
Under domains, one cannot simply open a connection to LOKI.BBN.COM, but must
instead ask the domain system where messages to LOKI.BBN.COM are to be delivered. And
the domain system may direct a mailer to deliver messages to an entirely different
host, such as SH.CS.NET. Or, in a more complicated case, the mailer may learn that it
has a choice of routes to LOKI.BBN.COM. This memo is essentially a set of guidelines
on how mailers should behave in this more complex world.
Readers are expected to be familiar with RFCs 882, 883, and the updates to them (e.g., RFC-973).
The domain servers store information as a series of resource records (RRs), each of
which contains a particular piece of information about a given domain name (which is
usually, but not always, a host). The simplest way to think of a RR is as a typed pair
of datum, a domain name matched with relevant data, and stored with some additional
type information to help systems determine when the RR is relevant. For the purposes
of message routing, the system stores RRs known as MX RRs. Each MX matches a domain
name with two pieces of data, a preference value (an unsigned 16-bit integer), and the
name of a host. The preference number is used to indicate in what order the mailer
should attempt deliver to the MX hosts, with the lowest numbered MX being the one to
try first. Multiple MXs with the same preference are permitted and have the same
priority.
In addition to mail information, the servers store certain other types of RR's
which mailers may encounter or choose to use. These are: the canonical name (CNAME)
RR, which simply states that the domain name queried for is actually an alias for
another domain name, which is the proper, or canonical, name; and the Well Known
Service (WKS) RR, which stores information about network services (such as SMTP) a
given domain name supports.
Before delving into a detailed discussion of how mailers are expected to do mail
routing, it would seem to make sense to give a brief overview of how this memo is
approaching the problems that routing poses.
The first major principle is derived from the definition of the preference field in
MX records, and is intended to prevent mail looping. If the mailer is on a host which
is listed as an MX for the destination host, the mailer may only deliver to an MX
which has a lower preference count than its own host.
The incomplete data problem also requires some care when handling domain queries.
If the answer section of a query is incomplete critical MX RRs may be left out. This
may result in mail looping, or in a message being mistakenly labelled undeliverable.
As a result, mailers may only accept responses from the domain system which have
complete answer sections. Note that this entire problem can be avoided by only using
virtual circuits for queries, but since this situation is likely to be very rare and
datagrams are the preferred way to interact with the domain system, implementors
should probably just ensure that their mailer will repeat a query with virtual
circuits should the truncation bit ever be set.
Determining Where to Send a Message - The explanation of how mailers should decide how
to route a message is discussed in terms of the problem of a mailer on a host with
domain name LOCAL trying to deliver a message addressed to the domain name REMOTE.
Both LOCAL and REMOTE are assumed to be syntactically correct domain names.
Furthermore, LOCAL is assumed to be the official name for the host on which the mailer
resides (i.e., it is not a alias).
Issuing a Query
The first step for the mailer at LOCAL is to issue a query for MX RRs for REMOTE.
It is strongly urged that this step be taken every time a mailer attempts to send the
message. The hope is that changes in the domain database will rapidly be used by
mailers, and thus domain administrators will be able to re-route in-transit messages
for defective hosts by simply changing their domain databases.
Certain responses to the query are considered errors:
Getting no response to the query. The domain server the mailer queried never
sends anything back. (This is distinct from an answer which contains no answers to the
query, which is not an error). Getting a response in which the truncation field of the
header is set. (Recall discussion of incomplete queries above). Mailers may not use
responses of this type, and should repeat the query using virtual circuits instead of
datagrams.
NOTE: This section only discusses how mailers choose which names to try to deliver
a message to, working from a list of RR's. It does not discuss how the mailers
actually make delivery. Where ever delivering a message is mentioned, all that is
meant is that the mailer should do whatever it needs to do to transfer a message to a
remote site, given a domain name for that site. (For example, an SMTP mailer will try
to get an address for the domain name, which involves another query to the domain
system, and then, if it gets an address, connect to the SMTP TCP port). The mechanics
of actually transferring the message over the network to the address associated with a
given domain name is not within the scope of this memo.
It is possible that the list of MXs in the response to the query will be empty.
This is a special case. If the list is empty, mailers should treat it as if it
contained one RR, an MX RR with a preference value of 0, and a host name of REMOTE.
(I.e., REMOTE is its only MX). In addition, the mailer should do no further processing
on the list, but should attempt to deliver the message to REMOTE. The idea here is
that if a domain fails to advertise any information about a particular name we will
give it the benefit of the doubt and attempt delivery.
If the list is not empty, the mailer should remove irrelevant RR's from the list
according to the following steps. Note that the orderis significant. For each MX, a
WKS query should be issued to see if the domain name listed actually supports the mail
service desired. MX RRs which list domain names which do not support the service
should be discarded. This step is optional, but strongly encouraged. If the domain
name LOCAL is listed as an MX RR, all MX RRs with a preference value greater than or
equal to that of LOCAL's must be discarded.
After removing irrelevant RRs, the list can again be empty. This is now an error
condition and can occur in several ways. The simplest case is that the WKS queries
have discovered that none of the hosts listed supports the mail service desired. The
message is thus deemed undeliverable, though extremely persistent mail systems might
want to try a delivery to REMOTE's address (if it exists) before returning the
message. Another, more dangerous, possibility is that the domain system believes that
LOCAL is handling message for REMOTE, but the mailer on LOCAL is not set up to handle
mail for REMOTE. For example, if the domain system lists LOCAL as the only MX for
REMOTE, LOCAL will delete all the entries in the list. But LOCAL is presumably
querying the domain system because it didn't know what to do with a message addressed
to REMOTE. Clearly something is wrong. How a mailer chooses to handle these situations
is to some extent implementation dependent, and is thus left to the implementor's
discretion.
If the list of MX RRs is not empty, the mailer should try to deliver the message to
the MXs in order (lowest preference value tried first). The mailer is required to
attempt delivery to the lowest valued MX. Implementors are encouraged to write mailers
so that they try the MXs in order until one of the MXs accepts the message, or all the
MXs have been tried. A somewhat less demanding system, in which a fixed number of MXs
is tried, is also reasonable. Note that multiple MXs may have the same preference
value. In this case, all MXs at with a given value must be tried before any of a
higher value are tried. In addition, in the special case in which there are several
MXs with the lowest preference value, all of them should be tried before a message is
deemed undeliverable.
Wildcard names, those containing the character '*' in them, may be used for mail
routing. There are likely to be servers on the network which simply state that any
mail to a domain is to be routed through a relay. For example, at the time that this
RFC is being written, all mail to hosts in the domain IL is routed through
RELAY.CS.NET. This is done by creating a wildcard RR, which states that *.IL has an MX
of RELAY.CS.NET. This should be transparent to the mailer since the domain servers
will hide this wildcard match. (If it matches *.IL with HUJI.IL for example, a domain
server will return an RR containing HUJI.IL, not *.IL). If by some accident a mailer
receives an RR with a wildcard domain name in its name or data section it should
discard the RR.
Note that the algorithm to delete irrelevant RRs breaks if LOCAL has a alias and
the alias is listed in the MX records for REMOTE. (E.g. REMOTE has an MX of ALIAS,
where ALIAS has a CNAME of LOCAL). This can be avoided if aliases are never used in
the data section of MX RRs.
Implementors should understand that the query and interpretation of the query is
only performed for REMOTE. It is not repeated for the MX RRs listed for REMOTE. You
cannot try to support more extravagant mail routing by building a chain of MXs. (E.g.
UNIX.BBN.COM is an MX for RELAY.CS.NET and RELAY.CS.NET is an MX for all the hosts
in .IL, but this does not mean that UNIX.BBN.COM accepts any responsibility for mail
for .IL).
Examples- To illustrate the discussion above, here are three examples of how mailers
should route messages. All examples work with the following database:
A.EXAMPLE.ORG IN MX 10 A.EXAMPLE.ORG
A.EXAMPLE.ORG IN MX 15 B.EXAMPLE.ORG
A.EXAMPLE.ORG IN MX 20 C.EXAMPLE.ORG
A.EXAMPLE.ORG IN WKS 10.0.0.1 TCP SMTP
B.EXAMPLE.ORG IN MX 0 B.EXAMPLE.ORG
B.EXAMPLE.ORG IN MX 10 C.EXAMPLE.ORG
B.EXAMPLE.ORG IN WKS 10.0.0.2 TCP SMTP
C.EXAMPLE.ORG IN MX 0 C.EXAMPLE.ORG
C.EXAMPLE.ORG IN WKS 10.0.0.3 TCP SMTP
D.EXAMPLE.ORG IN MX 0 D.EXAMPLE.ORG
D.EXAMPLE.ORG IN MX 0 C.EXAMPLE.ORG
D.EXAMPLE.ORG IN WKS 10.0.0.4 TCP SMTP
November 1995
SMTP Service Extensions
1. Abstract
This memo defines a framework for extending the SMTP service by defining a means
whereby a server SMTP can inform a client SMTP as to the service extensions it
supports. Extensions to the SMTP service are registered with the IANA. This framework
does not require modification of existing SMTP clients or servers unless the features
of the service extensions are to be requested or provided.
2. Introduction
The Simple Mail Transfer Protocol (SMTP) [1] has provided a stable, effective basis
for the relay function of message transfer agents. Although a decade old, SMTP has
proven remarkably resilient. Nevertheless, the need for a number of protocol
extensions has become evident. Rather than describing these extensions as separate and
haphazard entities, this document enhances SMTP in a straightforward
fashion that provides a framework in which all future extensions can be built in a
single consistent way.
3. Framework for SMTP Extensions
For the purpose of service extensions to SMTP, SMTP relays a mail object containing
an envelope and a content.
(1) The SMTP envelope is straightforward, and is sent as a series of SMTP protocol
units: it consists of an originator address (to which error reports should be
directed); a delivery mode (e.g., deliver to recipient mailboxes); and, one or more
recipient addresses.
(2) The SMTP content is sent in the SMTP DATA protocol unit and has two parts: the
headers and the body. The headers form a collection of field/value pairs structured
according to RFC 822 [2], whilst the body, if structured, is defined according to MIME
[3]. The content is textual in nature, expressed using the US ASCII repertoire (ANSI
X3.4-1986). Although extensions (such as MIME) may relax this restriction for the
content body, the content headers are always encoded using the US ASCII repertoire.
The algorithm defined in [4] is used to represent header values outside the US ASCII
repertoire, whilst still encoding them using the US ASCII repertoire.
Although SMTP is widely and robustly deployed, some parts of the Internet community
might wish to extend the SMTP service. This memo defines a means whereby both an
extended SMTP client and server may recognize each other as such and the server can
inform the client as to the service extensions that it supports.
It must be emphasized that any extension to the SMTP service should not be
considered lightly. SMTP's strength comes primarily from its simplicity. Experience
with many protocols has shown that:
protocols with few options tend towards ubiquity, whilst protocols with many
options tend towards obscurity.
This means that each and every extension, regardless of its benefits, must be
carefully scrutinized with respect to its implementation, deployment, and
interoperability costs. In many cases, the cost of extending the SMTP service will
likely outweigh the benefit.
Given this environment, the framework for the extensions described in this memo
consists of:
(1) a new SMTP command
(2) a registry of SMTP service extensions
(3) additional parameters to the SMTP MAIL FROM and RCPT TO commands
A client SMTP supporting SMTP service extensions should start an SMTP session by
issuing the EHLO command instead of the HELO command. If the SMTP server supports the
SMTP service extensions it will give a successful response , a failure response , or
an error response. If the SMTP server does not support any SMTP service extensions it
will generate an error response.
This specification is intended to extend STD 10, RFC 821 without impacting existing
services in any way. The minor changes needed are enumerated below.
RFC 821 states that the first command in an SMTP session must be the HELO command.
This requirement is hereby amended to allow a session to start with either EHLO or
HELO.
This specification extends the SMTP MAIL FROM and RCPT TO to allow additional
parameters and parameter values. It is possible that the MAIL FROM and RCPT TO lines
that result will exceed the 512 character limit on command line length imposed by RFC
821. This limit is hereby amended to only apply to command lines without any
parameters.
Each specification that defines new MAIL FROM or RCPT TO parameters must also
specify maximum parameter value lengths for each parameter so that implementors of
some set of extensions know how much buffer space must be allocated. The maximum
command length that must be supported by an SMTP implementation with extensions is 512
plus the sum of all the maximum parameter lengths for all the extensions supported.
The syntax for this command, using the ABNF notation of [2], is:
If successful, the server SMTP responds with code 250. On failure, the server SMTP
responds with code 550. On error, the server SMTP responds with one of codes 500, 501,
502, 504, or 421. This command is issued instead of the HELO command, and may be
issued at any time that a HELO command would be appropriate. That is, if the EHLO
command is issued, and a successful response is returned, then a subsequent HELO or
EHLO command will result in the server SMTP replying with code 503. A client SMTP
must not cache any information returned if the EHLO command succeeds. That is, a
client SMTP must issue the EHLO command at the start of each SMTP session if
information about extended facilities is needed.
4.3. Successful response
If the server SMTP implements and is able to perform the EHLO command, it will
return code 250. This indicates that both the server and client SMTP are in the
initial state, that is, there is no transaction in progress and all state tables and
buffers are cleared.
Normally, this response will be a multiline reply. Each line of the response
contains a keyword and, optionally, one or more parameters.
The IANA maintains a registry of SMTP service extensions. Associated with each such
extension is a corresponding EHLO keyword value. Each service extension registered
with the IANA must be defined in an RFC. Such RFCs must either be on the standards-
track or must define an IESG-approved experimental protocol. The definition must
include:
Any keyword values presented in the EHLO response that do not begin with "X" must
correspond to a standard, standards-track, or IESG-approved experimental SMTP service
extension registered with IANA. A conforming server must not offer non "X" prefixed
keyword values that are not described in a registered extension.
If for some reason the server SMTP is unable to list the service extensions it
supports, it will return code 554. In the case of a failure response, the client SMTP
should issue either the HELO or QUIT command.
If the server SMTP recognizes the EHLO command, but the command argument is
unacceptable, it will return code 501.
If the server SMTP recognizes, but does not implement, the EHLO command, it will
return code 502. If the server SMTP determines that the SMTP service is no longer
available (e.g., due to imminent system shutdown), it will return code 421. In the
case of any error response, the client SMTP should issue either the HELO or QUIT
command.
4.6. Responses from servers without extensions
A server SMTP that conforms to RFC 821 but does not support the extensions
specified here will not recognize the EHLO command and will consequently return code
500, as specified in RFC 821. The server SMTP should stay in the same state after
returning this code (see section 4.1.1 of RFC 821). The client SMTP may then issue
either a HELO or a QUIT command.
Some SMTP servers are known to disconnect the SMTP transmission channel upon
receipt of the EHLO command. The disconnect can occur immediately or after sending a
response. Such behavior violates section 4.1.1 of RFC 821, which explicitly states
that disconnection should only occur after a QUIT command is issued.
Other improperly-implemented servers will not accept a HELO command after EHLO has
been sent and rejected. In some cases, this problem can be worked around by sending a
RSET after the failure response to EHLO, then sending the HELO. Clients that do this
should be aware that many implementations will return a failure code (e.g., 503 Bad
sequence of commands) in response to the RSET. This code can be safely ignored.
5. Initial IANA Registry - The IANA's initial registry of SMTP service extensions
consists of these entries:
which correspond to those SMTP commands which are defined as optional in [5]. (The
mandatory SMTP commands, according to [5], are HELO, MAIL, RCPT, DATA, RSET, VRFY,
NOOP, and QUIT.)
It is recognized that several of the extensions planned for SMTP will make use of
additional parameters associated with the MAIL FROM and RCPT TO command.
If the server SMTP does not recognize or cannot implement one or more of the
parameters associated with a particular MAIL FROM or RCPT TO command, it will return
code 555. If for some reason the server is temporarily unable to accomodate one or
more of the parameters associated with a MAIL FROM or RCPT TO command, and if the
definition of the specific parameter does not mandate the use of another code, it
should return code 455. Errors specific to particular parameters and their values will
be specified in the parameter's defining RFC.
8. Usage Examples
indicates that the server SMTP implements only those SMTP commands which are
defined as mandatory in [5].
indicates that the server SMTP also implements the SMTP EXPN and HELP
commands, one standard service extension (8BITMIME), and two nonstandard and
unregistered service extensions (XONE and XVRB).
(3) Finally, a server that does not support SMTP service extensions would act as
follows:
S: <wait for connection on TCP port 25>
C: <open connection to server>
S: 220 dbc.mtview.ca.us SMTP service ready
C: EHLO ymir.claremont.edu
S: 500 Command not recognized: EHLO
...
The 500 response indicates that the server SMTP does not implement the
extensions specified here. The client would normally send a HELO command and proceed
as specified in RFC 821.
9. Security Considerations
This RFC does not discuss security issues and is not believed to raise any security
issues not already endemic in electronic mail and present in fully conforming
implementations of RFC-821. It does provide an announcement of server mail
capabilities via the response to the EHLO verb. However, all information provided by
announcement of any of the initial set of service extensions defined by this RFC can
be readily deduced by selective probing of the verbs required to transport and deliver
mail. The security implications of service extensions described in other RFCs should
be dealt with in those RFCs.