RFC 1854
SMTP Service Extension for Command Pipelining
RFC 1854: SMTP Service Extension for Command Pipelining π¬
Okay bestie, here's the title block tea β
- RFC number: 1854
- Working group: Network Working Group
- Authors: N. Freed (Innosoft International, Inc.) and A. Cargille, WG Chair
- Category: Standards Track
- Date: October 1995
- Obsoletes / Updates: the header doesn't list any RFCs that it obsoletes or updates π€·ββοΈ
Status of this Memo β¨
This is an Internet standards track protocol for the Internet community, and it's literally asking for discussion and suggestions for improvements π£οΈ. For the current standardization state and status, check the current edition of the "Internet Official Protocol Standards" (STD 1) π. Distribution of this memo is unlimited π.
Abstract π
This memo defines an extension to the SMTP service where a server can indicate how well it can accept multiple commands in a single TCP send operation. Using one TCP send operation for multiple commands can improve SMTP performance significantly π.
Introduction πΈ
Okay so, SMTP is widely and robustly deployed, but certain extensions may still prove useful π . In particular, lots of parts of the Internet use high latency network links π’.
SMTP's built-in one command-one response structure gets absolutely wrecked by high latency links π. It often gets to the point where most of the connection time is just spent waiting for responses to individual commands (turnaround time) β³.
In the best of all worlds, you could just deploy SMTP client software that uses command pipelining, which means batching up multiple commands into single TCP send operations π§. Unfortunately, the original SMTP specification [1] didn't explicitly state that SMTP servers must support this π. As a result, a non-trivial number of Internet SMTP servers cannot adequately handle command pipelining π. Flaws known to exist in deployed servers include:
- Connection handoff and buffer flushes in the middle of the SMTP dialogue. Creating server processes for incoming SMTP connections is a useful, obvious, and harmless implementation technique π. However, some SMTP servers defer process forking and connection handoff until some intermediate point in the SMTP dialogue. When this happens, material read from the TCP connection and kept in process buffers can be lost π.
- Flushing the TCP input buffer when an SMTP command fails. SMTP commands fail often, but there's no reason to flush the TCP input buffer when this happens. Still, some SMTP servers do exactly that π.
- Improper processing and promulgation of SMTP command failures. For example, some SMTP servers will refuse to accept a DATA command if the last RCPT TO command fails, paying no attention to whether prior RCPT TO command results succeeded or failed. Other servers will accept a DATA command even when all previous RCPT TO commands have failed. It's possible to accommodate this sort of behavior in a client that uses command pipelining, but it does complicate the construction of the client unnecessarily π€―.
This memo uses the mechanism described in [2] to define an extension to the SMTP service where an SMTP server can declare that it's capable of handling pipelined commands. The SMTP client can then check for this declaration and use pipelining only when the server declares itself capable of handling it β¨.
1. Framework for the Command Pipelining Extension π§©
The Command Pipelining extension is defined as follows:
- the name of the SMTP service extension is
Pipelining; - the EHLO keyword value associated with the extension is
PIPELINING; - no parameter is used with the
PIPELININGEHLO keyword; - no additional parameters are added to either the
MAIL FROMorRCPT TOcommands. - no additional SMTP verbs are defined by this extension; and,
- the next section specifies how support for the extension affects the behavior of a server and client SMTP.
2. The Pipelining Service Extension π
When a client SMTP wants to use command pipelining, it first issues the EHLO command to the server SMTP. If the server SMTP responds with code 250 to the EHLO command, and the response includes the EHLO keyword value PIPELINING, then the server SMTP has indicated that it can accommodate SMTP command pipelining π.
2.1. Client use of pipelining π¦
Once the client SMTP has confirmed that support exists for the pipelining extension, the client SMTP may then elect to send groups of SMTP commands in batches without waiting for a response to each individual command π¨. Specifically, RSET, MAIL FROM, SEND FROM, SOML FROM, SAML FROM, and RCPT TO can all appear anywhere in a pipelined command group π. EHLO, DATA, VRFY, EXPN, TURN, QUIT, and NOOP can only appear as the last command in a group, since their success or failure produces a change of state that the client SMTP has to accommodate π«Ά. (NOOP is in this group so it can be used as a synchronization point π.)
Additional commands added by other SMTP extensions may only appear as the last command in a group, unless the extensions that define those commands say otherwise π§Ύ.
Message content transfer is explicitly allowed to be the first "command" in a group π¨. That means the RSET/MAIL FROM sequence needed to start a new message transaction can go in the same group as the final transfer of the headers and body of the previous message π.
Client SMTP implementations that employ pipelining MUST check ALL statuses associated with each command in a group π. For example, if none of the RCPT TO recipient addresses were accepted, the client must then check the response to the DATA command. The client cannot assume that the DATA command will be rejected just because none of the RCPT TO commands worked π¬. If the DATA command was properly rejected, the client SMTP can just issue RSET. But if the DATA command was accepted, the client SMTP should send a single dot ..
Command statuses MUST be coordinated with responses by counting each separate response and correlating that count with the number of commands known to have been issued π’. Multiline responses MUST be supported. Matching on the basis of either the error code value or associated text is expressly forbidden π«.
Client SMTP implementations MAY elect to operate in a nonblocking fashion, processing server responses immediately upon receipt, even if there is still data pending transmission from the client's previous TCP send operation π. If nonblocking operation is not supported, however, client SMTP implementations MUST also check the TCP window size and make sure that each group of commands fits entirely within the window πͺ. The window size is usually, but not always, 4K octets. Failure to perform this check can lead to deadlock conditions π.
Clients MUST NOT confuse responses to multiple commands with multiline responses. Each command requires one or more lines of response, and the last line doesn't contain a dash between the response code and the response string π ββοΈ.
2.2. Server support of pipelining π₯οΈ
A server SMTP implementation that offers the pipelining extension:
- MUST NOT flush or otherwise lose the contents of the TCP input buffer under any circumstances whatsoever.
- SHOULD issue a positive response to the DATA command if and only if one or more valid RCPT TO addresses have been previously received.
- MUST NOT, after issuing a positive response to a DATA command with no valid recipients and subsequently receiving an empty message, send any message whatsoever to anybody.
- SHOULD elect to store responses to grouped RSET, MAIL FROM, SEND FROM, SOML FROM, SAML FROM, and RCPT TO commands in an internal buffer so they can sent as a unit.
- MUST NOT buffer responses to EHLO, DATA, VRFY, EXPN, TURN, QUIT, and NOOP.
- MUST NOT buffer responses to unrecognized commands.
- MUST send all pending responses immediately whenever the local TCP input buffer is emptied.
- MUST NOT make assumptions about commands that are yet to be received.
- SHOULD issue response text that indicates, either implicitly or explicitly, what command the response matches.
The overriding intent of these server requirements is to make it as easy as possible for servers to conform to these pipelining extensions π§ π.
3. Examples π
Consider the following SMTP dialogue that does not use pipelining:
S: <wait for open connection>
C: <open connection to server>
S: 220 innosoft.com SMTP service ready
C: HELO dbc.mtview.ca.us
S: 250 innosoft.com
C: MAIL FROM:<mrose@dbc.mtview.ca.us>
S: 250 sender <mrose@dbc.mtview.ca.us> OK
C: RCPT TO:<ned@innosoft.com>
S: 250 recipient <ned@innosoft.com> OK
C: RCPT TO:<dan@innosoft.com>
S: 250 recipient <dan@innosoft.com> OK
C: RCPT TO:<kvc@innosoft.com>
S: 250 recipient <kvc@innosoft.com> OK
C: DATA
S: 354 enter mail, end with line containing only "."
...
C: .
S: 250 message sent
C: QUIT
S: 221 goodbye
The client waits for a server response a total of 9 times in this simple example π΄. But if pipelining is employed, the following dialogue is possible:
S: <wait for open connection>
C: <open connection to server>
S: 220 innosoft.com SMTP service ready
C: EHLO dbc.mtview.ca.us
S: 250-innosoft.com
S: 250 PIPELINING
C: MAIL FROM:<mrose@dbc.mtview.ca.us>
C: RCPT TO:<ned@innosoft.com>
C: RCPT TO:<dan@innosoft.com>
C: RCPT TO:<kvc@innosoft.com>
C: DATA
S: 250 sender <mrose@dbc.mtview.ca.us> OK
S: 250 recipient <ned@innosoft.com> OK
S: 250 recipient <dan@innosoft.com> OK
S: 250 recipient <kvc@innosoft.com> OK
S: 354 enter mail, end with line containing only "."
...
C: .
C: QUIT
S: 250 message sent
S: 221 goodbye
The total number of turnarounds has been reduced from 9 to 4 π
The next example illustrates one possible form of behavior when pipelining is used and all recipients are rejected π:
S: <wait for open connection>
C: <open connection to server>
S: 220 innosoft.com SMTP service ready
C: EHLO dbc.mtview.ca.us
S: 250-innosoft.com
S: 250 PIPELINING
C: MAIL FROM:<mrose@dbc.mtview.ca.us>
C: RCPT TO:<nsb@thumper.bellcore.com>
C: RCPT TO:<galvin@tis.com>
C: DATA
S: 250 sender <mrose@dbc.mtview.ca.us> OK
S: 550 remote mail to <nsb@thumper.bellore.com> not allowed
S: 550 remote mail to <galvin@tis.com> not allowed
S: 554 no valid recipients given
C: QUIT
S: 221 goodbye
The client SMTP waits for the server 4 times here as well π« . If the server SMTP does not check for at least one valid recipient prior to accepting the DATA command, the following dialogue would result:
S: <wait for open connection>
C: <open connection to server>
S: 220 innosoft.com SMTP service ready
C: EHLO dbc.mtview.ca.us
S: 250-innosoft.com
S: 250 PIPELINING
C: MAIL FROM:<mrose@dbc.mtview.ca.us>
C: RCPT TO:<nsb@thumper.bellcore.com>
C: RCPT TO:<galvin@tis.com>
C: DATA
S: 250 sender <mrose@dbc.mtview.ca.us> OK
S: 550 remote mail to <nsb@thumper.bellore.com> not allowed
S: 550 remote mail to <galvin@tis.com> not allowed
S: 354 enter mail, end with line containing only "."
C: .
C: QUIT
S: 554 no valid recipients
S: 221 goodbye
4. Security Considerations πβ¨
okay bestie, this doc is not going deep on security π It 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 [1]. So the vibe is: the security stuff that exists is the email stuff that already exists π Nothing new is being added here, and that's the whole tea β
5. Acknowledgements π«Ά
this one is giving gratitude π The document is based on the SMTP service extension model presented in RFC 1425. Marshall Rose also gets love for his description of SMTP command pipelining in his book "The Internet Message," which served as a source of inspiration for this extension πβ¨ Iconic inspo, honestly.
6. References π
[1] Postel, J., "Simple Mail Transfer Protocol", STD 10 RFC 821, USC/Information Sciences Institute, August 1982.
[2] Klensin, J., Freed, N., Rose, M., Stefferud, E., and D. Crocker, "SMTP Service Extensions", RFC 1651, MCI, Innosoft, Dover Beach Consulting, Inc., Network Management Associates, Inc., Silicon Graphics, Inc., July 1994. πΈ
7. Author's Address π
the author is Ned Freed, and here's where to find him π§
Ned Freed
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
π¦ where this page comes from
- ietf: rfc1854 1995-10
- π girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms