Network Working Group J. Klensin
Request for Comments: 5321 October 2008
Category: Standards Track
Simple Mail Transfer Protocol
Status of This Memo
This document specifies an Internet standards track protocol for the
Internet community, and requests discussion and suggestions for
improvements. Please refer to the current edition of the "Internet
Official Protocol Standards" (STD 1) for the standardization state
and status of this protocol. Distribution of this memo is unlimited.
This document is a specification of the basic protocol for Internet
electronic mail transport. It consolidates, updates, and clarifies
several previous documents, making all or parts of most of them
obsolete. It covers the SMTP extension mechanisms and best practices
for the contemporary Internet, but does not provide details about
particular extensions. Although SMTP was designed as a mail
transport and delivery protocol, this specification also contains
information that is important to its use as a "mail submission"
protocol for "split-UA" (User Agent) mail reading systems and mobile
1.1. Transport of Electronic Mail
The objective of the Simple Mail Transfer Protocol (SMTP) is to
transfer mail reliably and efficiently.
SMTP is independent of the particular transmission subsystem and
requires only a reliable ordered data stream channel. While this
document specifically discusses transport over TCP, other transports
are possible. Appendices to RFC 821  describe some of them.
An important feature of SMTP is its capability to transport mail
across multiple networks, usually referred to as "SMTP mail relaying"
(see Section 3.6). A network consists of the mutually-TCP-accessible
hosts on the public Internet, the mutually-TCP-accessible hosts on a
firewall-isolated TCP/IP Intranet, or hosts in some other LAN or WAN
environment utilizing a non-TCP transport-level protocol. Using
SMTP, a process can transfer mail to another process on the same
network or to some other network via a relay or gateway process
accessible to both networks.
In this way, a mail message may pass through a number of intermediate
relay or gateway hosts on its path from sender to ultimate recipient.
The Mail eXchanger mechanisms of the domain name system (RFC 1035
, RFC 974 , and Section 5 of this document) are used to
identify the appropriate next-hop destination for a message being
1.2. History and Context for This Document
This document is a specification of the basic protocol for the
Internet electronic mail transport. It consolidates, updates and
clarifies, but does not add new or change existing functionality of
o the original SMTP (Simple Mail Transfer Protocol) specification of
RFC 821 ,
o domain name system requirements and implications for mail
transport from RFC 1035  and RFC 974 ,
o the clarifications and applicability statements in RFC 1123 ,
o material drawn from the SMTP Extension mechanisms in RFC 1869
o Editorial and clarification changes to RFC 2821  to bring that
specification to Draft Standard.
It obsoletes RFC 821, RFC 974, RFC 1869, and RFC 2821 and updates RFC
1123 (replacing the mail transport materials of RFC 1123). However,
RFC 821 specifies some features that were not in significant use in
the Internet by the mid-1990s and (in appendices) some additional
transport models. Those sections are omitted here in the interest of
clarity and brevity; readers needing them should refer to RFC 821.
It also includes some additional material from RFC 1123 that required
amplification. This material has been identified in multiple ways,
mostly by tracking flaming on various lists and newsgroups and
problems of unusual readings or interpretations that have appeared as
the SMTP extensions have been deployed. Where this specification
moves beyond consolidation and actually differs from earlier
documents, it supersedes them technically as well as textually.
Although SMTP was designed as a mail transport and delivery protocol,
this specification also contains information that is important to its
use as a "mail submission" protocol, as recommended for Post Office
Protocol (POP) (RFC 937 , RFC 1939 ) and IMAP (RFC 3501
). In general, the separate mail submission protocol specified
in RFC 4409  is now preferred to direct use of SMTP; more
discussion of that subject appears in that document.
Section 2.3 provides definitions of terms specific to this document.
Except when the historical terminology is necessary for clarity, this
document uses the current 'client' and 'server' terminology to
identify the sending and receiving SMTP processes, respectively.
A companion document, RFC 5322 , discusses message header sections
and bodies and specifies formats and structures for them.
1.3. Document Conventions
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in RFC 2119 . As each
of these terms was intentionally and carefully chosen to improve the
interoperability of email, each use of these terms is to be treated
as a conformance requirement.
Because this document has a long history and to avoid the risk of
various errors and of confusing readers and documents that point to
this one, most examples and the domain names they contain are
preserved from RFC 2821. Readers are cautioned that these are
illustrative examples that should not actually be used in either code
or configuration files.
2. The SMTP Model
2.1. Basic Structure
The SMTP design can be pictured as:
+------+ | | | |
| User |<-->| | SMTP | |
+------+ | Client- |Commands/Replies| Server- |
+------+ | SMTP |<-------------->| SMTP | +------+
| File |<-->| | and Mail | |<-->| File |
|System| | | | | |System|
+------+ +----------+ +----------+ +------+
SMTP client SMTP server
When an SMTP client has a message to transmit, it establishes a two-
way transmission channel to an SMTP server. The responsibility of an
SMTP client is to transfer mail messages to one or more SMTP servers,
or report its failure to do so.
The means by which a mail message is presented to an SMTP client, and
how that client determines the identifier(s) ("names") of the
domain(s) to which mail messages are to be transferred, is a local
matter, and is not addressed by this document. In some cases, the
designated domain(s), or those determined by an SMTP client, will
identify the final destination(s) of the mail message. In other
cases, common with SMTP clients associated with implementations of
the POP (RFC 937 , RFC 1939 ) or IMAP (RFC 3501 )
protocols, or when the SMTP client is inside an isolated transport
service environment, the domain determined will identify an
intermediate destination through which all mail messages are to be
relayed. SMTP clients that transfer all traffic regardless of the
target domains associated with the individual messages, or that do
not maintain queues for retrying message transmissions that initially
cannot be completed, may otherwise conform to this specification but
are not considered fully-capable. Fully-capable SMTP
implementations, including the relays used by these less capable
ones, and their destinations, are expected to support all of the
queuing, retrying, and alternate address functions discussed in this
specification. In many situations and configurations, the less-
capable clients discussed above SHOULD be using the message
submission protocol (RFC 4409 ) rather than SMTP.
The means by which an SMTP client, once it has determined a target
domain, determines the identity of an SMTP server to which a copy of
a message is to be transferred, and then performs that transfer, is
covered by this document. To effect a mail transfer to an SMTP
server, an SMTP client establishes a two-way transmission channel to
that SMTP server. An SMTP client determines the address of an
appropriate host running an SMTP server by resolving a destination
domain name to either an intermediate Mail eXchanger host or a final
An SMTP server may be either the ultimate destination or an
intermediate "relay" (that is, it may assume the role of an SMTP
client after receiving the message) or "gateway" (that is, it may
transport the message further using some protocol other than SMTP).
SMTP commands are generated by the SMTP client and sent to the SMTP
server. SMTP replies are sent from the SMTP server to the SMTP
client in response to the commands.
In other words, message transfer can occur in a single connection
between the original SMTP-sender and the final SMTP-recipient, or can
occur in a series of hops through intermediary systems. In either
case, once the server has issued a success response at the end of the
mail data, a formal handoff of responsibility for the message occurs:
the protocol requires that a server MUST accept responsibility for
either delivering the message or properly reporting the failure to do
so (see Sections 6.1, 6.2, and 7.8, below).
Once the transmission channel is established and initial handshaking
is completed, the SMTP client normally initiates a mail transaction.
Such a transaction consists of a series of commands to specify the
originator and destination of the mail and transmission of the
message content (including any lines in the header section or other
structure) itself. When the same message is sent to multiple
recipients, this protocol encourages the transmission of only one
copy of the data for all recipients at the same destination (or
intermediate relay) host.
The server responds to each command with a reply; replies may
indicate that the command was accepted, that additional commands are
expected, or that a temporary or permanent error condition exists.
Commands specifying the sender or recipients may include server-
permitted SMTP service extension requests, as discussed in
Section 2.2. The dialog is purposely lock-step, one-at-a-time,
although this can be modified by mutually agreed upon extension
requests such as command pipelining (RFC 2920 ).
Once a given mail message has been transmitted, the client may either
request that the connection be shut down or may initiate other mail
transactions. In addition, an SMTP client may use a connection to an
SMTP server for ancillary services such as verification of email
addresses or retrieval of mailing list subscriber addresses.
As suggested above, this protocol provides mechanisms for the
transmission of mail. Historically, this transmission normally
occurred directly from the sending user's host to the receiving
user's host when the two hosts are connected to the same transport
service. When they are not connected to the same transport service,
transmission occurs via one or more relay SMTP servers. A very
common case in the Internet today involves submission of the original
message to an intermediate, "message submission" server, which is
similar to a relay but has some additional properties; such servers
are discussed in Section 2.3.10 and at some length in RFC 4409 .
An intermediate host that acts as either an SMTP relay or as a
gateway into some other transmission environment is usually selected
through the use of the domain name service (DNS) Mail eXchanger
Usually, intermediate hosts are determined via the DNS MX record, not
by explicit "source" routing (see Section 5 and Appendix C and
2.2. The Extension Model
In an effort that started in 1990, approximately a decade after RFC
821 was completed, the protocol was modified with a "service
extensions" model that permits the client and server to agree to
utilize shared functionality beyond the original SMTP requirements.
The SMTP extension mechanism defines a means whereby an extended SMTP
client and server may recognize each other, and the server can inform
the client as to the service extensions that it supports.
Contemporary SMTP implementations MUST support the basic extension
mechanisms. For instance, servers MUST support the EHLO command even
if they do not implement any specific extensions and clients SHOULD
preferentially utilize EHLO rather than HELO. (However, for
compatibility with older conforming implementations, SMTP clients and
servers MUST support the original HELO mechanisms as a fallback.)
Unless the different characteristics of HELO must be identified for
interoperability purposes, this document discusses only EHLO.
SMTP is widely deployed and high-quality implementations have proven
to be very robust. However, the Internet community now considers
some services to be important that were not anticipated when the
protocol was first designed. If support for those services is to be
added, it must be done in a way that permits older implementations to
continue working acceptably. The extension framework consists of:
o The SMTP command EHLO, superseding the earlier HELO,
o a registry of SMTP service extensions,
o additional parameters to the SMTP MAIL and RCPT commands, and
o optional replacements for commands defined in this protocol, such
as for DATA in non-ASCII transmissions (RFC 3030 ).
SMTP's strength comes primarily from its simplicity. Experience with
many protocols has shown that protocols with few options tend towards
ubiquity, whereas protocols with many options tend towards obscurity.
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.
2.2.2. Definition and Registration of Extensions
The IANA maintains a registry of SMTP service extensions. A
corresponding EHLO keyword value is associated with each extension.
Each service extension registered with the IANA must be defined in a
formal Standards-Track or IESG-approved Experimental protocol
document. The definition must include:
o the textual name of the SMTP service extension;
o the EHLO keyword value associated with the extension;
o the syntax and possible values of parameters associated with the
EHLO keyword value;
o any additional SMTP verbs associated with the extension
(additional verbs will usually be, but are not required to be, the
same as the EHLO keyword value);
o any new parameters the extension associates with the MAIL or RCPT
o a description of how support for the extension affects the
behavior of a server and client SMTP; and
o the increment by which the extension is increasing the maximum
length of the commands MAIL and/or RCPT, over that specified in
In addition, any EHLO keyword value starting with an upper or lower
case "X" refers to a local SMTP service extension used exclusively
through bilateral agreement. Keywords beginning with "X" MUST NOT be
used in a registered service extension. Conversely, 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.
Additional verbs and parameter names are bound by the same rules as
EHLO keywords; specifically, verbs beginning with "X" are local
extensions that may not be registered or standardized. Conversely,
verbs not beginning with "X" must always be registered.
2.2.3. Special Issues with Extensions
Extensions that change fairly basic properties of SMTP operation are
permitted. The text in other sections of this document must be
understood in that context. In particular, extensions can change the
minimum limits specified in Section 4.5.3, can change the ASCII
character set requirement as mentioned above, or can introduce some
optional modes of message handling.
In particular, if an extension implies that the delivery path
normally supports special features of that extension, and an
intermediate SMTP system finds a next hop that does not support the
required extension, it MAY choose, based on the specific extension
and circumstances, to requeue the message and try later and/or try an
alternate MX host. If this strategy is employed, the timeout to fall
back to an unextended format (if one is available) SHOULD be less
than the normal timeout for bouncing as undeliverable (e.g., if
normal timeout is three days, the requeue timeout before attempting
to transmit the mail without the extension might be one day).
2.3. SMTP Terminology
2.3.1. Mail Objects
SMTP transports a mail object. A mail object contains an envelope
The SMTP envelope is sent as a series of SMTP protocol units
(described in Section 3). It consists of an originator address (to
which error reports should be directed), one or more recipient
addresses, and optional protocol extension material. Historically,
variations on the reverse-path (originator) address specification
command (MAIL) could be used to specify alternate delivery modes,
such as immediate display; those variations have now been deprecated
(see Appendix F and Appendix F.6).
The SMTP content is sent in the SMTP DATA protocol unit and has two
parts: the header section and the body. If the content conforms to
other contemporary standards, the header section consists of a
collection of header fields, each consisting of a header name, a
colon, and data, structured as in the message format specification
(RFC 5322 ); the body, if structured, is defined according to MIME
(RFC 2045 ). The content is textual in nature, expressed using
the US-ASCII repertoire . Although SMTP extensions (such as
"8BITMIME", RFC 1652 ) may relax this restriction for the content
body, the content header fields are always encoded using the US-ASCII
repertoire. Two MIME extensions (RFC 2047  and RFC 2231 )
define an algorithm for representing header values outside the US-
ASCII repertoire, while still encoding them using the US-ASCII
2.3.2. Senders and Receivers
In RFC 821, the two hosts participating in an SMTP transaction were
described as the "SMTP-sender" and "SMTP-receiver". This document
has been changed to reflect current industry terminology and hence
refers to them as the "SMTP client" (or sometimes just "the client")
and "SMTP server" (or just "the server"), respectively. Since a
given host may act both as server and client in a relay situation,
"receiver" and "sender" terminology is still used where needed for
2.3.3. Mail Agents and Message Stores
Additional mail system terminology became common after RFC 821 was
published and, where convenient, is used in this specification. In
particular, SMTP servers and clients provide a mail transport service
and therefore act as "Mail Transfer Agents" (MTAs). "Mail User
Agents" (MUAs or UAs) are normally thought of as the sources and
targets of mail. At the source, an MUA might collect mail to be
transmitted from a user and hand it off to an MTA; the final
("delivery") MTA would be thought of as handing the mail off to an
MUA (or at least transferring responsibility to it, e.g., by
depositing the message in a "message store"). However, while these
terms are used with at least the appearance of great precision in
other environments, the implied boundaries between MUAs and MTAs
often do not accurately match common, and conforming, practices with
Internet mail. Hence, the reader should be cautious about inferring
the strong relationships and responsibilities that might be implied
if these terms were used elsewhere.
For the purposes of this specification, a host is a computer system
attached to the Internet (or, in some cases, to a private TCP/IP
network) and supporting the SMTP protocol. Hosts are known by names
(see the next section); they SHOULD NOT be identified by numerical
addresses, i.e., by address literals as described in Section 4.1.2.
2.3.5. Domain Names
A domain name (or often just a "domain") consists of one or more
components, separated by dots if more than one appears. In the case
of a top-level domain used by itself in an email address, a single
string is used without any dots. This makes the requirement,
described in more detail below, that only fully-qualified domain
names appear in SMTP transactions on the public Internet,
particularly important where top-level domains are involved. These
components ("labels" in DNS terminology, RFC 1035 ) are restricted
for SMTP purposes to consist of a sequence of letters, digits, and
hyphens drawn from the ASCII character set . Domain names are
used as names of hosts and of other entities in the domain name
hierarchy. For example, a domain may refer to an alias (label of a
CNAME RR) or the label of Mail eXchanger records to be used to
deliver mail instead of representing a host name. See RFC 1035 
and Section 5 of this specification.
The domain name, as described in this document and in RFC 1035 ,
is the entire, fully-qualified name (often referred to as an "FQDN").
A domain name that is not in FQDN form is no more than a local alias.
Local aliases MUST NOT appear in any SMTP transaction.
Only resolvable, fully-qualified domain names (FQDNs) are permitted
when domain names are used in SMTP. In other words, names that can
be resolved to MX RRs or address (i.e., A or AAAA) RRs (as discussed
in Section 5) are permitted, as are CNAME RRs whose targets can be
resolved, in turn, to MX or address RRs. Local nicknames or
unqualified names MUST NOT be used. There are two exceptions to the
rule requiring FQDNs:
o The domain name given in the EHLO command MUST be either a primary
host name (a domain name that resolves to an address RR) or, if
the host has no name, an address literal, as described in
Section 4.1.3 and discussed further in the EHLO discussion of
o The reserved mailbox name "postmaster" may be used in a RCPT
command without domain qualification (see Section 184.108.40.206) and
MUST be accepted if so used.
2.3.6. Buffer and State Table
SMTP sessions are stateful, with both parties carefully maintaining a
common view of the current state. In this document, we model this
state by a virtual "buffer" and a "state table" on the server that
may be used by the client to, for example, "clear the buffer" or
"reset the state table", causing the information in the buffer to be
discarded and the state to be returned to some previous state.
2.3.7. Commands and Replies
SMTP commands and, unless altered by a service extension, message
data, are transmitted from the sender to the receiver via the
transmission channel in "lines".
An SMTP reply is an acknowledgment (positive or negative) sent in
"lines" from receiver to sender via the transmission channel in
response to a command. The general form of a reply is a numeric
completion code (indicating failure or success) usually followed by a
text string. The codes are for use by programs and the text is
usually intended for human users. RFC 3463 , specifies further
structuring of the reply strings, including the use of supplemental
and more specific completion codes (see also RFC 5248 ).
Lines consist of zero or more data characters terminated by the
sequence ASCII character "CR" (hex value 0D) followed immediately by
ASCII character "LF" (hex value 0A). This termination sequence is
denoted as <CRLF> in this document. Conforming implementations MUST
NOT recognize or generate any other character or character sequence
as a line terminator. Limits MAY be imposed on line lengths by
servers (see Section 4).
In addition, the appearance of "bare" "CR" or "LF" characters in text
(i.e., either without the other) has a long history of causing
problems in mail implementations and applications that use the mail
system as a tool. SMTP client implementations MUST NOT transmit
these characters except when they are intended as line terminators
and then MUST, as indicated above, transmit them only as a <CRLF>
2.3.9. Message Content and Mail Data
The terms "message content" and "mail data" are used interchangeably
in this document to describe the material transmitted after the DATA
command is accepted and before the end of data indication is
transmitted. Message content includes the message header section and
the possibly structured message body. The MIME specification (RFC
2045 ) provides the standard mechanisms for structured message
2.3.10. Originator, Delivery, Relay, and Gateway Systems
This specification makes a distinction among four types of SMTP
systems, based on the role those systems play in transmitting
electronic mail. An "originating" system (sometimes called an SMTP
originator) introduces mail into the Internet or, more generally,
into a transport service environment. A "delivery" SMTP system is
one that receives mail from a transport service environment and
passes it to a mail user agent or deposits it in a message store that
a mail user agent is expected to subsequently access. A "relay" SMTP
system (usually referred to just as a "relay") receives mail from an
SMTP client and transmits it, without modification to the message
data other than adding trace information, to another SMTP server for
further relaying or for delivery.
A "gateway" SMTP system (usually referred to just as a "gateway")
receives mail from a client system in one transport environment and
transmits it to a server system in another transport environment.
Differences in protocols or message semantics between the transport
environments on either side of a gateway may require that the gateway
system perform transformations to the message that are not permitted
to SMTP relay systems. For the purposes of this specification,
firewalls that rewrite addresses should be considered as gateways,
even if SMTP is used on both sides of them (see RFC 2979 ).
2.3.11. Mailbox and Address
As used in this specification, an "address" is a character string
that identifies a user to whom mail will be sent or a location into
which mail will be deposited. The term "mailbox" refers to that
depository. The two terms are typically used interchangeably unless
the distinction between the location in which mail is placed (the
mailbox) and a reference to it (the address) is important. An
address normally consists of user and domain specifications. The
standard mailbox naming convention is defined to be
"local-part@domain"; contemporary usage permits a much broader set of
applications than simple "user names". Consequently, and due to a
long history of problems when intermediate hosts have attempted to
optimize transport by modifying them, the local-part MUST be
interpreted and assigned semantics only by the host specified in the
domain part of the address.
2.4. General Syntax Principles and Transaction Model
SMTP commands and replies have a rigid syntax. All commands begin
with a command verb. All replies begin with a three digit numeric
code. In some commands and replies, arguments are required following
the verb or reply code. Some commands do not accept arguments (after
the verb), and some reply codes are followed, sometimes optionally,
by free form text. In both cases, where text appears, it is
separated from the verb or reply code by a space character. Complete
definitions of commands and replies appear in Section 4.
Verbs and argument values (e.g., "TO:" or "to:" in the RCPT command
and extension name keywords) are not case sensitive, with the sole
exception in this specification of a mailbox local-part (SMTP
Extensions may explicitly specify case-sensitive elements). That is,
a command verb, an argument value other than a mailbox local-part,
and free form text MAY be encoded in upper case, lower case, or any
mixture of upper and lower case with no impact on its meaning. The
local-part of a mailbox MUST BE treated as case sensitive.
Therefore, SMTP implementations MUST take care to preserve the case
of mailbox local-parts. In particular, for some hosts, the user
"smith" is different from the user "Smith". However, exploiting the
case sensitivity of mailbox local-parts impedes interoperability and
is discouraged. Mailbox domains follow normal DNS rules and are
hence not case sensitive.
A few SMTP servers, in violation of this specification (and RFC 821)
require that command verbs be encoded by clients in upper case.
Implementations MAY wish to employ this encoding to accommodate those
The argument clause consists of a variable-length character string
ending with the end of the line, i.e., with the character sequence
<CRLF>. The receiver will take no action until this sequence is
The syntax for each command is shown with the discussion of that
command. Common elements and parameters are shown in Section 4.1.2.
Commands and replies are composed of characters from the ASCII
character set . 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.
More specifically, the unextended SMTP service provides 7-bit
transport only. An originating SMTP client that has not successfully
negotiated an appropriate extension with a particular server (see the
next paragraph) MUST NOT transmit messages with information in the
high-order bit of octets. If such messages are transmitted in
violation of this rule, receiving SMTP servers MAY clear the high-
order bit or reject the message as invalid. In general, a relay SMTP
SHOULD assume that the message content it has received is valid and,
assuming that the envelope permits doing so, relay it without
inspecting that content. Of course, if the content is mislabeled and
the data path cannot accept the actual content, this may result in
the ultimate delivery of a severely garbled message to the recipient.
Delivery SMTP systems MAY reject such messages, or return them as
undeliverable, rather than deliver them. In the absence of a server-
offered extension explicitly permitting it, a sending SMTP system is
not permitted to send envelope commands in any character set other
than US-ASCII. Receiving systems SHOULD reject such commands,
normally using "500 syntax error - invalid character" replies.
8-bit message content transmission MAY be requested of the server by
a client using extended SMTP facilities, notably the "8BITMIME"
extension, RFC 1652 . 8BITMIME SHOULD be supported by SMTP
servers. However, it MUST NOT be construed as authorization to
transmit unrestricted 8-bit material, nor does 8BITMIME authorize
transmission of any envelope material in other than ASCII. 8BITMIME
MUST NOT be requested by senders for material with the high bit on
that is not in MIME format with an appropriate content-transfer
encoding; servers MAY reject such messages.
The metalinguistic notation used in this document corresponds to the
"Augmented BNF" used in other Internet mail system documents. The
reader who is not familiar with that syntax should consult the ABNF
specification in RFC 5234 . Metalanguage terms used in running
text are surrounded by pointed brackets (e.g., <CRLF>) for clarity.
The reader is cautioned that the grammar expressed in the
metalanguage is not comprehensive. There are many instances in which
provisions in the text constrain or otherwise modify the syntax or
semantics implied by the grammar.