RFC du protocole SMTP : specifications
4. THE SMTP SPECIFICATIONS
4.1. SMTP COMMANDS
4.1.1. COMMAND SEMANTICS
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. The SMTP replies are discussed in the Section 4.2.
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. These arguments or
data objects must be transmitted and held pending the
confirmation communicated by the end of mail data indication
which finalizes the transaction. The model for this is that
distinct buffers are provided to hold the types of data
objects, that is, there is a reverse-path buffer, a
forward-path buffer, and a mail data buffer. Specific commands
cause information to be appended to a specific buffer, or cause
one or more buffers to be cleared.
HELLO (HELO)
This command is used to identify the sender-SMTP to the
receiver-SMTP. The argument field contains the host name of
the sender-SMTP.
The receiver-SMTP identifies itself to the sender-SMTP in
the connection greeting reply, and in the response to this
command.
This command and an OK reply to it confirm that both the
sender-SMTP and the receiver-SMTP are in the initial state,
that is, there is no transaction in progress and all state
tables and buffers are cleared.
MAIL (MAIL)
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 (see Example 7).
This command clears the reverse-path buffer, the
forward-path buffer, and the mail data buffer; and inserts
the reverse-path information from this command into the
reverse-path buffer.
RECIPIENT (RCPT)
This command is used to identify an individual recipient of
the mail data; multiple recipients are specified by multiple
use of this command.
The forward-path consists of an optional list of hosts and a
required destination mailbox. When the list of hosts is
present, it is a source route and indicates that the mail
must be relayed to the next host on the list. If the
receiver-SMTP does not implement the relay function it may
user the same reply it would for an unknown local user
(550).
When mail is relayed, the relay host must remove itself from
the beginning forward-path and put itself at the beginning
of the reverse-path. When mail reaches its ultimate
destination (the forward-path contains only a destination
mailbox), the receiver-SMTP inserts it into the destination
mailbox in accordance with its host mail conventions.
For example, mail received at relay host A with arguments
FROM:<USERX@HOSTY.ARPA>
TO:<@HOSTA.ARPA,@HOSTB.ARPA:USERC@HOSTD.ARPA>
will be relayed on to host B with arguments
FROM:<@HOSTA.ARPA:USERX@HOSTY.ARPA>
TO:<@HOSTB.ARPA:USERC@HOSTD.ARPA>.
This command causes its forward-path argument to be appended
to the forward-path buffer.
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>" (see
Section 4.5.2 on Transparency). 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.
Here, final delivery means the message leaves the SMTP
world. Normally, this would mean it has been delivered to
the destination user, but in some cases it may be further
processed and transmitted by another mail system.
It is possible for the mailbox in the return path be
different from the actual sender's mailbox, for example,
if error responses are to be delivered a special error
handling mailbox rather than the message senders.
The preceding two paragraphs imply that the final mail data
will begin with a return path line, followed by one or more
time stamp lines. These lines will be followed by the mail
data header and body [2]. See Example 8.
Special mention is needed of the response and further action
required when the processing following the end of mail data
indication is partially successful. This could arise if
after accepting several recipients and the mail data, the
receiver-SMTP finds that the mail data can be successfully
delivered to some of the recipients, but it cannot be to
others (for example, due to mailbox space allocation
problems). In such a situation, the response to the DATA
command must be an OK reply. But, the receiver-SMTP must
compose and send an "undeliverable mail" notification
message to the originator of the message. Either a single
notification which lists all of the recipients that failed
to get the message, or separate notification messages must
be sent for each failed recipient (see Example 7). 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
This is to inform you that ...
Example 8
-------------------------------------------------------------
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.
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).
This command clears the reverse-path buffer, the
forward-path buffer, and the mail data buffer; and inserts
the reverse-path information from this command into the
reverse-path buffer.
SEND OR MAIL (SOML)
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.
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).
This command clears the reverse-path buffer, the
forward-path buffer, and the mail data buffer; and inserts
the reverse-path information from this command into the
reverse-path buffer.
SEND AND MAIL (SAML)
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.
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).
This command clears the reverse-path buffer, the
forward-path buffer, and the mail data buffer; and inserts
the reverse-path information from this command into the
reverse-path buffer.
RESET (RSET)
This command specifies that the current mail transaction is
to be aborted. Any stored sender, recipients, and mail data
must be discarded, and all buffers and state tables cleared.
The receiver must send an OK reply.
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.
This command has no effect on any of the reverse-path
buffer, the forward-path buffer, or the mail data buffer.
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.
This command has no effect on any of the reverse-path
buffer, the forward-path buffer, or the mail data buffer.
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.
This command has no effect on any of the reverse-path
buffer, the forward-path buffer, or the mail data buffer.
NOOP (NOOP)
This command does not affect any parameters or previously
entered commands. It specifies no action other than that
the receiver send an OK reply.
This command has no effect on any of the reverse-path
buffer, the forward-path buffer, or the mail data buffer.
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 the
sender-SMTP, or (2) send a refusal reply and retain the role
of the receiver-SMTP.
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. Program-A is then in the initial
state as if the transmission channel just opened, and it
then sends the 220 service ready greeting.
If program-B is currently the receiver-SMTP and it receives
the TURN command and sends an OK reply (250) then program-B
becomes the sender-SMTP. Program-B is then in the initial
state as if the transmission channel just opened, and it
then expects to receive the 220 service ready greeting.
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.
If the transaction beginning command argument is not
acceptable a 501 failure reply must be returned and the
receiver-SMTP must stay in the same state. If the commands
in a transaction are out of order a 503 failure reply must
be returned and the receiver-SMTP must stay in the same
state.
The last command in a session must be the QUIT command. The
QUIT command can not be used at any other time in a session.
4.1.2. COMMAND SYNTAX
The commands consist of a command code followed by an argument
field. Command codes are four alphabetic characters. Upper
and lower case alphabetic characters are to be treated
identically. Thus, any of the following may represent the mail
command:
MAIL Mail mail MaIl mAIl
This also applies to any symbols representing parameter values,
such as "TO" or "to" for the forward-path. Command codes and
the argument fields are separated by one or more spaces.
However, within the reverse-path and forward-path arguments
case is important. In particular, in some hosts the user
"smith" is different from the user "Smith".
The argument field consists of a variable length character
string ending with the character sequence <CRLF>. The receiver
is to take no action until this sequence is received.
Square brackets denote an optional argument field. If the
option is not taken, the appropriate default is implied.
The following are the SMTP commands:
HELO <SP> <domain> <CRLF>
MAIL <SP> FROM:<reverse-path> <CRLF>
RCPT <SP> TO:<forward-path> <CRLF>
DATA <CRLF>
RSET <CRLF>
SEND <SP> FROM:<reverse-path> <CRLF>
SOML <SP> FROM:<reverse-path> <CRLF>
SAML <SP> FROM:<reverse-path> <CRLF>
VRFY <SP> <string> <CRLF>
EXPN <SP> <string> <CRLF>
HELP [<SP> <string>] <CRLF>
NOOP <CRLF>
QUIT <CRLF>
TURN <CRLF>
The syntax of the above argument fields (using BNF notation
where applicable) is given below. The "..." notation indicates
that a field may be repeated one or more times.
<reverse-path> ::= <path>
<forward-path> ::= <path>
<path> ::= "<" [ <a-d-l> ":" ] <mailbox> ">"
<a-d-l> ::= <at-domain> | <at-domain> "," <a-d-l>
<at-domain> ::= "@" <domain>
<domain> ::= <element> | <element> "." <domain>
<element> ::= <name> | "#" <number> | "[" <dotnum> "]"
<mailbox> ::= <local-part> "@" <domain>
<local-part> ::= <dot-string> | <quoted-string>
<name> ::= <a> <ldh-str> <let-dig>
<ldh-str> ::= <let-dig-hyp> | <let-dig-hyp> <ldh-str>
<let-dig> ::= <a> | <d>
<let-dig-hyp> ::= <a> | <d> | "-"
<dot-string> ::= <string> | <string> "." <dot-string>
<string> ::= <char> | <char> <string>
<quoted-string> ::= """ <qtext> """
<qtext> ::= "\" <x> | "\" <x> <qtext> | <q> | <q> <qtext>
<char> ::= <c> | "\" <x>
<dotnum> ::= <snum> "." <snum> "." <snum> "." <snum>
<number> ::= <d> | <d> <number>
<CRLF> ::= <CR> <LF>
<CR> ::= the carriage return character (ASCII code 13)
<LF> ::= the line feed character (ASCII code 10)
<SP> ::= the space character (ASCII code 32)
<snum> ::= one, two, or three digits representing a decimal
integer value in the range 0 through 255
<a> ::= any one of the 52 alphabetic characters A through Z
in upper case and a through z in lower case
<c> ::= any one of the 128 ASCII characters, but not any
<special> or <SP>
<d> ::= any one of the ten digits 0 through 9
<q> ::= any one of the 128 ASCII characters except <CR>,
<LF>, quote ("), or backslash (\)
<x> ::= any one of the 128 ASCII characters (no exceptions)
<special> ::= "<" | ">" | "(" | ")" | "[" | "]" | "\" | "."
| "," | ";" | ":" | "@" """ | the control
characters (ASCII codes 0 through 31 inclusive and
127)
Note that the backslash, "\", is a quote character, which is
used to indicate that the next character is to be used
literally (instead of its normal interpretation). For example,
"Joe\,Smith" could be used to indicate a single nine character
user field with comma being the fourth character of the field.
Hosts are generally known by names which are translated to
addresses in each host. Note that the name elements of domains
are the official names -- no use of nicknames or aliases is
allowed.
Sometimes a host is not known to the translation function and
communication is blocked. To bypass this barrier two numeric
forms are also allowed for host "names". One form is a decimal
integer prefixed by a pound sign, "#", which indicates the
number is the address of the host. Another form is four small
decimal integers separated by dots and enclosed by brackets,
e.g., "[123.255.37.2]", which indicates a 32-bit ARPA Internet
Address in four 8-bit fields.
The time stamp line and the return path line are formally
defined as follows:
<return-path-line> ::= "Return-Path:" <SP><reverse-path><CRLF>
<time-stamp-line> ::= "Received:" <SP> <stamp> <CRLF>
<stamp> ::= <from-domain> <by-domain> <opt-info> ";"
<daytime>
<from-domain> ::= "FROM" <SP> <domain> <SP>
<by-domain> ::= "BY" <SP> <domain> <SP>
<opt-info> ::= [<via>] [<with>] [<id>] [<for>]
<via> ::= "VIA" <SP> <link> <SP>
<with> ::= "WITH" <SP> <protocol> <SP>
<id> ::= "ID" <SP> <string> <SP>
<for> ::= "FOR" <SP> <path> <SP>
<link> ::= The standard names for links are registered with
the Network Information Center.
<protocol> ::= The standard names for protocols are
registered with the Network Information Center.
<daytime> ::= <SP> <date> <SP> <time>
<date> ::= <dd> <SP> <mon> <SP> <yy>
<time> ::= <hh> ":" <mm> ":" <ss> <SP> <zone>
<dd> ::= the one or two decimal integer day of the month in
the range 1 to 31.
<mon> ::= "JAN" | "FEB" | "MAR" | "APR" | "MAY" | "JUN" |
"JUL" | "AUG" | "SEP" | "OCT" | "NOV" | "DEC"
<yy> ::= the two decimal integer year of the century in the
range 00 to 99.
<hh> ::= the two decimal integer hour of the day in the
range 00 to 24.
<mm> ::= the two decimal integer minute of the hour in the
range 00 to 59.
<ss> ::= the two decimal integer second of the minute in the
range 00 to 59.
<zone> ::= "UT" for Universal Time (the default) or other
time zone designator (as in [2]).
-------------------------------------------------------------
Return Path Example
Return-Path: <@CHARLIE.ARPA,@BAKER.ARPA:JOE@ABLE.ARPA>
Example 9
-------------------------------------------------------------
-------------------------------------------------------------
Time Stamp Line Example
Received: FROM ABC.ARPA BY XYZ.ARPA ; 22 OCT 81 09:23:59 PDT
Received: from ABC.ARPA by XYZ.ARPA via TELENET with X25
id M12345 for Smith@PDQ.ARPA ; 22 OCT 81 09:23:59 PDT
Example 10
-------------------------------------------------------------
4.2. SMTP REPLIES
Replies to SMTP commands are devised to ensure the synchronization
of requests and actions in the process of mail transfer, and to
guarantee that the sender-SMTP always knows the state of the
receiver-SMTP. Every command must generate exactly one reply.
The details of the command-reply sequence are made explicit in
Section 5.3 on Sequencing and Section 5.4 State Diagrams.
An SMTP reply consists of a three digit number (transmitted as
three alphanumeric characters) followed by some text. The number
is intended for use by automata to determine what state to enter
next; the text is meant for the human user. It is intended that
the three digits contain enough encoded information that the
sender-SMTP need not examine the text and may either discard it or
pass it on to the user, as appropriate. In particular, the text
may be receiver-dependent and context dependent, so there are
likely to be varying texts for each reply code. A discussion of
the theory of reply codes is given in Appendix E. Formally, a
reply is defined to be the sequence: a three-digit code, <SP>,
one line of text, and <CRLF>, or a multiline reply (as defined in
Appendix E). Only the EXPN and HELP commands are expected to
result in multiline replies in normal circumstances, however
multiline replies are allowed for any command.
4.2.1. REPLY CODES BY FUNCTION GROUPS
500 Syntax error, command unrecognized
[This may include errors such as command line too long]
501 Syntax error in parameters or arguments
502 Command not implemented
503 Bad sequence of commands
504 Command parameter not implemented
211 System status, or system help reply
214 Help message
[Information on how to use the receiver or the meaning of a
particular non-standard command; this reply is useful only
to the human user]
220 <domain> Service ready
221 <domain> Service closing transmission channel
421 <domain> Service not available,
closing transmission channel
[This may be a reply to any command if the service knows it
must shut down]
250 Requested mail action okay, completed
251 User not local; will forward to <forward-path>
450 Requested mail action not taken: mailbox unavailable
[E.g., mailbox busy]
550 Requested action not taken: mailbox unavailable
[E.g., mailbox not found, no access]
451 Requested action aborted: error in processing
551 User not local; please try <forward-path>
452 Requested action not taken: insufficient system storage
552 Requested mail action aborted: exceeded storage allocation
553 Requested action not taken: mailbox name not allowed
[E.g., mailbox syntax incorrect]
354 Start mail input; end with <CRLF>.<CRLF>
554 Transaction failed
4.2.2. NUMERIC ORDER LIST OF REPLY CODES
211 System status, or system help reply
214 Help message
[Information on how to use the receiver or the meaning of a
particular non-standard command; this reply is useful only
to the human user]
220 <domain> Service ready
221 <domain> Service closing transmission channel
250 Requested mail action okay, completed
251 User not local; will forward to <forward-path>
354 Start mail input; end with <CRLF>.<CRLF>
421 <domain> Service not available,
closing transmission channel
[This may be a reply to any command if the service knows it
must shut down]
450 Requested mail action not taken: mailbox unavailable
[E.g., mailbox busy]
451 Requested action aborted: local error in processing
452 Requested action not taken: insufficient system storage
500 Syntax error, command unrecognized
[This may include errors such as command line too long]
501 Syntax error in parameters or arguments
502 Command not implemented
503 Bad sequence of commands
504 Command parameter not implemented
550 Requested action not taken: mailbox unavailable
[E.g., mailbox not found, no access]
551 User not local; please try <forward-path>
552 Requested mail action aborted: exceeded storage allocation
553 Requested action not taken: mailbox name not allowed
[E.g., mailbox syntax incorrect]
554 Transaction failed
4.3. SEQUENCING OF COMMANDS AND REPLIES
The communication between the sender and receiver is intended to
be an alternating dialogue, controlled by the sender. As such,
the sender issues a command and the receiver responds with a
reply. The sender must wait for this response before sending
further commands.
One important reply is the connection greeting. Normally, a
receiver will send a 220 "Service ready" reply when the connection
is completed. The sender should wait for this greeting message
before sending any commands.
Note: all the greeting type replies have the official name of
the server host as the first word following the reply code.
For example,
220 <SP> USC-ISIF.ARPA <SP> Service ready <CRLF>
The table below lists alternative success and failure replies for
each command. These must be strictly adhered to; a receiver may
substitute text in the replies, but the meaning and action implied
by the code numbers and by the specific command reply sequence
cannot be altered.
COMMAND-REPLY SEQUENCES
Each command is listed with its possible replies. The prefixes
used before the possible replies are "P" for preliminary (not
used in SMTP), "I" for intermediate, "S" for success, "F" for
failure, and "E" for error. The 421 reply (service not
available, closing transmission channel) may be given to any
command if the SMTP-receiver knows it must shut down. This
listing forms the basis for the State Diagrams in Section 4.4.
CONNECTION ESTABLISHMENT
S: 220
F: 421
HELO
S: 250
E: 500, 501, 504, 421
MAIL
S: 250
F: 552, 451, 452
E: 500, 501, 421
RCPT
S: 250, 251
F: 550, 551, 552, 553, 450, 451, 452
E: 500, 501, 503, 421
DATA
I: 354 -> data -> S: 250
F: 552, 554, 451, 452
F: 451, 554
E: 500, 501, 503, 421
RSET
S: 250
E: 500, 501, 504, 421
SEND
S: 250
F: 552, 451, 452
E: 500, 501, 502, 421
SOML
S: 250
F: 552, 451, 452
E: 500, 501, 502, 421
SAML
S: 250
F: 552, 451, 452
E: 500, 501, 502, 421
VRFY
S: 250, 251
F: 550, 551, 553
E: 500, 501, 502, 504, 421
EXPN
S: 250
F: 550
E: 500, 501, 502, 504, 421
HELP
S: 211, 214
E: 500, 501, 502, 504, 421
NOOP
S: 250
E: 500, 421
QUIT
S: 221
E: 500
TURN
S: 250
F: 502
E: 500, 503
4.4. STATE DIAGRAMS
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".
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.
A more complex diagram models the DATA command:
+---+ DATA +---+ 1,2 +---+
| B |---------->| W |-------------------->| E |
+---+ +---+ ------------>+---+
3| |4,5 |
| | |
-------------- ----- |
| | | +---+
| ---------- -------->| S |
| | | | +---+
| | ------------
| | | |
V 1,3| |2 |
+---+ data +---+ --------------->+---+
| |---------->| W | | F |
+---+ +---+-------------------->+---+
4,5
Note that the "data" here is a series of lines sent from the
sender to the receiver with no response expected until the last
line is sent.
4.5. DETAILS
4.5.1. MINIMUM IMPLEMENTATION
In order to make SMTP workable, the following minimum
implementation is required for all receivers:
COMMANDS -- HELO
MAIL
RCPT
DATA
RSET
NOOP
QUIT
4.5.2. TRANSPARENCY
Without some provision for data transparency the character
sequence "<CRLF>.<CRLF>" ends the mail text and cannot be sent
by the user. In general, users are not aware of such
"forbidden" sequences. To allow all user composed text to be
transmitted transparently the following procedures are used.
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.
2. When a line of mail text is received by the receiver-SMTP
it checks the line. If the line is composed of a single
period it is the end of mail. If the first character is a
period and there are other characters on the line, the first
character is deleted.
The mail data may contain any of the 128 ASCII characters. All
characters are to be delivered to the recipient's mailbox
including format effectors and other control characters. If
the transmission channel provides an 8-bit byte (octets) data
stream, the 7-bit ASCII codes are transmitted right justified
in the octets with the high order bits cleared to zero.
In some systems it may be necessary to transform the data as
it is received and stored. This may be necessary for hosts
that use a different character set than ASCII as their local
character set, or that store data in records rather than
strings. If such transforms are necessary, they must be
reversible -- especially if such transforms are applied to
mail being relayed.
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.
****************************************************
* *
* TO THE MAXIMUM EXTENT POSSIBLE, IMPLEMENTATION *
* TECHNIQUES WHICH IMPOSE NO LIMITS ON THE LENGTH *
* OF THESE OBJECTS SHOULD BE USED. *
* *
****************************************************
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.
path
The maximum total length of a reverse-path or
forward-path is 256 characters (including the punctuation
and element separators).
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).
recipients buffer
The maximum total number of recipients that must be
buffered is 100 recipients.
****************************************************
* *
* TO THE MAXIMUM EXTENT POSSIBLE, IMPLEMENTATION *
* TECHNIQUES WHICH IMPOSE NO LIMITS ON THE LENGTH *
* OF THESE OBJECTS SHOULD BE USED. *
* *
****************************************************
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.
|