RFC 1869

SMTP Service Extensions

๐Ÿ“… published November 1995, from ietf

RFC 1869: SMTP Service Extensions โœจ

okay bestie, this is RFC 1869, called SMTP Service Extensions, and it comes out of the Network Working Group ๐ŸŽ€ It's a Standards Track doc dated November 1995, and it's part of STD 10 ๐Ÿ’œ It also obsoletes RFC 1651, so 1651 is out and this is the new hotness ๐Ÿ’…

The people behind it are J. Klensin (WG Chair, MCI), N. Freed (Editor, Innosoft International, Inc.), M. Rose (Dover Beach Consulting, Inc.), E. Stefferud (Network Management Associates, Inc.), and D. Crocker (Brandenburg Consulting) ๐Ÿซถ


Status of this Memo ๐Ÿ“œ

So this doc is an Internet standards track protocol for the whole Internet community, and it's literally asking for discussion and suggestions for improvements ๐Ÿฆ‹ If you want to know where this protocol stands right now, check the current edition of the "Internet Official Protocol Standards" (STD 1) ๐Ÿ‘‘ Distribution of this memo is unlimited, so share away ๐ŸŒˆ

1. Abstract โœจ

This memo sets up a framework for extending the SMTP service ๐Ÿงš The big idea is that a server SMTP can tell a client SMTP which service extensions it supports, and those extensions get registered with the IANA. The best part is that 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. So your old clients and servers are fine unless they actually want the new stuff ๐Ÿ’…

2. Introduction ๐ŸŒธ

SMTP [1] has been the stable, effective basis for the relay function of message transfer agents ๐Ÿ“ It's a decade old and it's STILL super resilient ๐Ÿ˜ญ But yeah, we do need a bunch of extensions now. Instead of letting them become separate, haphazard little things, this doc upgrades SMTP in a straightforward way, with a framework where all future extensions can be built in one consistent way โœจ

3. Framework for SMTP Extensions ๐Ÿฆ‹

For extensions to SMTP, SMTP relays a mail object that contains an envelope and content ๐Ÿ“ฌ

  1. The SMTP envelope is straightforward and gets sent as a series of SMTP protocol units. It has an originator address (where error reports go ๐Ÿšจ), 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 are a collection of field/value pairs structured according to RFC 822 [2], and the body, if structured, is defined according to MIME [3]. The content is textual, using the US ASCII repertoire (ANSI X3.4-1986). Extensions like MIME may relax that restriction for the body, but the headers are always encoded in US ASCII. The algorithm in [4] is used to represent header values outside the US ASCII repertoire while still encoding them in US ASCII ๐Ÿง

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, bestie: any extension to the SMTP service should not be considered lightly ๐Ÿ˜ค SMTP's strength comes mainly 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.

So every single extension, no matter how good its benefits are, must be carefully scrutinized for its implementation, deployment, and interoperability costs. In many cases, the cost of extending the SMTP service will likely outweigh the benefit ๐Ÿ’€

Given all that, the framework for the extensions in this memo consists of:

  1. a new SMTP command (section 4)
  2. a registry of SMTP service extensions (section 5)
  3. additional parameters to the SMTP MAIL FROM and RCPT TO commands (section 6).

4. The EHLO command ๐Ÿ’œ

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 (see section 4.3), a failure response (see 4.4), or an error response (4.5). If the SMTP server doesn't support any SMTP service extensions, it will generate an error response (see section 4.5) ๐Ÿ™ˆ

4.1. Changes to STD 10, RFC 821 โœจ

This spec is meant to extend STD 10, RFC 821 without messing with existing services in any way ๐Ÿซถ The minor changes needed are listed below.

4.1.1. First command

RFC 821 states that the first command in an SMTP session must be the HELO command. That requirement is now amended to allow a session to start with either EHLO or HELO ๐Ÿฆ‹

4.1.2. Maximum command line length

This spec extends the SMTP MAIL FROM and RCPT TO commands to allow additional parameters and parameter values. The MAIL FROM and RCPT TO lines that result might go over the 512 character limit on command line length that RFC 821 imposes. That limit is now 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 implementors of a set of extensions know how much buffer space to allocate ๐Ÿ“ 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 ๐Ÿงฎ

4.2. Command syntax

The syntax for this command, using the ABNF notation of [2], is:

     ehlo-cmd ::= "EHLO" SP domain CR LF

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 it may be issued any time a HELO command would be appropriate. That means if the EHLO command is issued and a successful response is returned, then a subsequent HELO or EHLO command will get the server SMTP replying with code 503 ๐Ÿ™ƒ A client SMTP must not cache any information returned if the EHLO command succeeds. In other words, a client SMTP must issue the EHLO command at the start of each SMTP session if it needs information about extended facilities โœจ

4.3. Successful response

If the server SMTP implements and is able to perform the EHLO command, it will return code 250. This means both the server and client SMTP are in the initial state: there's no transaction in progress, and all state tables and buffers are cleared ๐Ÿงผ

Normally this response is a multiline reply. Each line has a keyword and, optionally, one or more parameters. The syntax for a positive response, using the ABNF notation of [2], is:

     ehlo-ok-rsp  ::=      "250"    domain [ SP greeting ] CR LF
                    / (    "250-"   domain [ SP greeting ] CR LF
                        *( "250-"      ehlo-line           CR LF )
                           "250"    SP ehlo-line           CR LF   )

                  ; the usual HELO chit-chat
     greeting     ::= 1*<any character other than CR or LF>

     ehlo-line    ::= ehlo-keyword *( SP ehlo-param )

     ehlo-keyword ::= (ALPHA / DIGIT) *(ALPHA / DIGIT / "-")

                  ; syntax and values depend on ehlo-keyword
     ehlo-param   ::= 1*<any CHAR excluding SP and all
                         control characters (US ASCII 0-31
                         inclusive)>

     ALPHA        ::= <any one of the 52 alphabetic characters
                       (A through Z in upper case, and,
                        a through z in lower case)>
     DIGIT        ::= <any one of the 10 numeric characters
                       (0 through 9)>

     CR           ::= <the carriage-return character
                       (ASCII decimal code 13)>
     LF           ::= <the line-feed character
                       (ASCII decimal code 10)>

     SP           ::= <the space character
                       (ASCII decimal code 32)>

Even though EHLO keywords can be upper, lower, or mixed case, they must always be recognized and processed in a case-insensitive way. This is just an extension of what RFC 821 started ๐Ÿง 

The IANA keeps a registry of SMTP service extensions ๐Ÿ“š Each extension in it has a matching EHLO keyword value. Each service extension registered with the IANA must be defined in an RFC. Those RFCs must either be on the standards track or define an IESG-approved experimental protocol. The definition must include:

  1. the textual name of the SMTP service extension;
  2. the EHLO keyword value associated with the extension;
  3. the syntax and possible values of parameters associated with the EHLO keyword value;
  4. 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);
  5. any new parameters the extension associates with the MAIL FROM or RCPT TO verbs;
  6. how support for the extension affects the behavior of a server and client SMTP; and,
  7. the increment by which the extension is increasing the maximum length of the commands MAIL FROM, RCPT TO, or both, over that specified in RFC 821.

Also, any EHLO keyword value that starts with an upper or lower case X refers to a local SMTP service extension. That's used through bilateral agreement rather than standardized agreement ๐Ÿค Keywords beginning with X may not be used in a registered service extension ๐Ÿšซ

Any keyword values in the EHLO response that don't 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 aren't described in a registered extension ๐Ÿ™…โ€โ™€๏ธ

Additional verbs follow the same rules as EHLO keywords. Specifically, verbs beginning with X are local extensions that may not be registered or standardized, and verbs not beginning with X must always be registered ๐ŸŽ€

4.4. Failure response

If for some reason the server SMTP can't 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 ๐Ÿ‘‹

4.5. Error responses from extended servers

If the server SMTP recognizes the EHLO command but the command argument is unacceptable, it will return code 501 ๐Ÿ™ˆ

If the server SMTP recognizes the EHLO command but doesn't implement it, 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 ๐ŸŒธ

Okay so a server that follows RFC 821 but doesn't support the extensions in this doc won't recognize EHLO at all ๐Ÿ™ˆ It'll reply with 500, just like RFC 821 says. The server should stay in the same state after sending that 500 (see section 4.1.1 of RFC 821). Then the client can either try HELO or send QUIT ๐Ÿซถ

4.7. Responses from improperly implemented servers ๐Ÿ’€

Some SMTP servers are known to disconnect the SMTP transmission channel as soon as they get EHLO. ngl that's rude ๐Ÿ˜ญ The disconnect can happen right away or after the server sends a response. This behavior violates section 4.1.1 of RFC 821, which explicitly says disconnection should only happen after a QUIT command is issued.

Still, for the sake of maximum interoperability, it's suggested that extended SMTP clients using EHLO be coded to check for server connection closure after EHLO is sent, either before or after returning a reply. If this happens, the client must decide whether the operation can be successfully completed without using any SMTP extensions. If it can, a new connection can be opened and the HELO command can be used ๐Ÿฆ‹

Other improperly-implemented servers won't accept a HELO command after EHLO has been sent and rejected. Sometimes you can work around this by sending RSET after the failure response to EHLO, then sending the HELO. Clients doing this should know that lots of implementations will return a failure code (e.g., 503 Bad sequence of commands) in response to the RSET. That code can be safely ignored ๐Ÿ’…

5. Initial IANA Registry ๐ŸŽ€

The IANA's initial registry of SMTP service extensions has these entries:

Service Ext   EHLO Keyword Parameters Verb       Added Behavior
------------- ------------ ---------- ---------- ------------------
Send             SEND         none       SEND    defined in RFC 821
Send or Mail     SOML         none       SOML    defined in RFC 821
Send and Mail    SAML         none       SAML    defined in RFC 821
Expand           EXPN         none       EXPN    defined in RFC 821
Help             HELP         none       HELP    defined in RFC 821
Turn             TURN         none       TURN    defined in RFC 821

These correspond to the SMTP commands that are defined as optional in [5]. (The mandatory SMTP commands, according to [5], are HELO, MAIL, RCPT, DATA, RSET, VRFY, NOOP, and QUIT.) Main character energy for the mandatory crew ๐Ÿ‘‘

6. MAIL FROM and RCPT TO Parameters ๐Ÿงš

It's recognized that several of the extensions planned for SMTP will make use of additional parameters tied to the MAIL FROM and RCPT TO commands. The syntax for these commands, using the ABNF notation of [2] along with the underlying definitions from [1], is:

  esmtp-cmd        ::= inner-esmtp-cmd [SP esmtp-parameters] CR LF
  esmtp-parameters ::= esmtp-parameter *(SP esmtp-parameter)
  esmtp-parameter  ::= esmtp-keyword ["=" esmtp-value]
  esmtp-keyword    ::= (ALPHA / DIGIT) *(ALPHA / DIGIT / "-")

                       ; syntax and values depend on esmtp-keyword
  esmtp-value      ::= 1*<any CHAR excluding "=", SP, and all
                          control characters (US ASCII 0-31
                          inclusive)>

                       ; The following commands are extended to
                       ; accept extended parameters.
  inner-esmtp-cmd  ::= ("MAIL FROM:" reverse-path)   /
                       ("RCPT TO:" forward-path)

All esmtp-keyword values must be registered as part of the IANA registration process described above. This definition only provides the framework for future extensions. No extended MAIL FROM or RCPT TO parameters are defined by this RFC ๐ŸŒˆ

6.1. Error responses ๐Ÿ’–

If the server SMTP doesn't recognize or can't implement one or more of the parameters attached to a particular MAIL FROM or RCPT TO command, it will return code 555.

If for some reason the server is temporarily unable to accommodate one or more of the parameters attached to a MAIL FROM or RCPT TO command, and the definition of that specific parameter doesn't require a different code, it should return code 455.

Errors specific to particular parameters and their values will be specified in the parameter's defining RFC.

7. Received: Header Field Annotation ๐Ÿฆ‹

SMTP servers are required to add an appropriate Received: field to the headers of all messages they receive. A "with ESMTP" clause should be added to this field whenever any SMTP service extensions are used. "ESMTP" is hereby added to the list of standard protocol names registered with IANA โœจ

8. Usage Examples ๐Ÿ“

(1) Here's an interaction that looks like this:

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: 250 dbc.mtview.ca.us says hello
 ...

This means the server SMTP only implements those SMTP commands that are defined as mandatory in [5] ๐ŸŒธ

(2) Now compare that with this one:

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: 250-dbc.mtview.ca.us says hello
S: 250-EXPN
S: 250-HELP
S: 250-8BITMIME
S: 250-XONE
S: 250 XVRB
 ...

This shows 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). Iconic behavior ๐Ÿ”ฅ

(3) Finally, here's a server that doesn't support SMTP service extensions:

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 means the server SMTP doesn't implement the extensions specified here. The client would normally send a HELO command and proceed as specified in RFC 821. See section 4.7 for additional discussion ๐Ÿ™ˆ

9. Security Considerations ๐Ÿ’€

Okay, serious moment, bestie ๐Ÿ˜ญ This RFC doesn't discuss security issues, and it isn't believed to raise any security issues that aren't already endemic to electronic mail and present in fully conforming implementations of RFC 821. It does provide an announcement of server mail capabilities through the response to the EHLO verb. However, all information provided by the announcement of any of the initial set of service extensions defined by this RFC can be readily deduced by selectively probing 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 ๐Ÿ”ฅ

10. Acknowledgements ๐Ÿซถ

This document is a synthesis of the ideas of many people, and of reactions to the ideas and proposals of others. Randall Atkinson, Craig Everhart, Risto Kankkunen, and Greg Vaudreuil contributed ideas and text sufficient to be considered co-authors. Other important suggestions, text, or encouragement came from Harald Alvestrand, Jim Conklin, Mark Crispin, Frank da Cruz, 'Olafur Gudmundsson, Per Hedeland, Christian Huitma, Neil Katin, Eliot Lear, Harold A. Miller, Keith Moore, John Myers, Dan Oscarsson, Julian Onions, Rayan Zachariassen, and the contributions of the entire IETF SMTP Working Group. Of course, none of these individuals are necessarily responsible for the combination of ideas represented here. Honestly, in some cases the response to a particular criticism was to accept the problem identification but include an entirely different solution from the one originally proposed ๐Ÿ’œ

11. References ๐Ÿ“š

[1] Postel, J., "Simple Mail Transfer Protocol", STD 10, RFC 821,
    USC/Information Sciences Institute, August 1982.

[2] Crocker, D., "Standard for the Format of ARPA Internet Text
    Messages", STD 11, RFC 822, UDEL, August 1982.

[3] Borenstein, N., and N. Freed, "Multipurpose Internet Mail
    Extensions", RFC 1521, Bellcore, Innosoft, September 1993.

[4] Moore, K., "Representation of Non-ASCII Text in Internet Message
    Headers", RFC 1522, University of Tennessee, September 1993.

[5] Braden, R., "Requirements for Internet Hosts - Application and
    Support", STD 3, RFC 1123, USC/Information Sciences Institute,
    October 1989.

12. Chair, Editor, and Author Addresses ๐ŸŒŸ

John Klensin, WG Chair
MCI
2100 Reston Parkway
Reston, VA 22091

Phone: +1 703 715-7361
Fax: +1 703 715-7436
EMail: klensin@mci.net

Ned Freed, Editor
Innosoft International, Inc.
1050 East Garvey Avenue South
West Covina, CA 91790
USA

Phone: +1 818 919 3600
Fax: +1 818 919 3614
EMail: ned@innosoft.com

Marshall T. Rose
Dover Beach Consulting, Inc.
420 Whisman Court
Moutain View, CA  94043-2186
USA

Phone: +1 415 968 1052
Fax: +1 415 968 2510
EMail: mrose@dbc.mtview.ca.us

Einar A. Stefferud
Network Management Associates, Inc.
17301 Drey Lane
Huntington Beach, CA, 92647-5615
USA

Phone: +1 714 842 3711
Fax: +1 714 848 2091
EMail: stef@nma.com

Dave Crocker
Brandenburg Consulting
675 Spruce Dr.
Sunnyvale, CA 94086 USA
USA

Phone: +1 408 246 8253
Fax: +1 408 249 6205
EMail: dcrocker@mordor.stanford.edu

That's the whole RFC, bestie ๐ŸŒˆ๐Ÿ’–โœจ

๐Ÿ“ฆ where this page comes from