rfc1854.txt 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. Network Working Group N. Freed
  2. Request For Comments: 1854 Innosoft International, Inc.
  3. Category: Standards Track A. Cargille, WG Chair
  4. October 1995
  5. SMTP Service Extension
  6. for Command Pipelining
  7. Status of this Memo
  8. This document specifies an Internet standards track protocol for the
  9. Internet community, and requests discussion and suggestions for
  10. improvements. Please refer to the current edition of the "Internet
  11. Official Protocol Standards" (STD 1) for the standardization state
  12. and status of this protocol. Distribution of this memo is unlimited.
  13. Abstract
  14. This memo defines an extension to the SMTP service whereby a server
  15. can indicate the extent of its ability to accept multiple commands in
  16. a single TCP send operation. Using a single TCP send operation for
  17. multiple commands can improve SMTP performance significantly.
  18. Introduction
  19. Although SMTP is widely and robustly deployed, certain extensions may
  20. nevertheless prove useful. In particular, many parts of the Internet
  21. make use of high latency network links.
  22. SMTP's intrinsic one command-one response structure is significantly
  23. penalized by high latency links, often to the point where the factors
  24. contributing to overall connection time are dominated by the time
  25. spent waiting for responses to individual commands (turnaround time).
  26. In the best of all worlds it would be possible to simply deploy SMTP
  27. client software that makes use of command pipelining: batching up
  28. multiple commands into single TCP send operations. Unfortunately, the
  29. original SMTP specification [1] did not explicitly state that SMTP
  30. servers must support this. As a result a non-trivial number of
  31. Internet SMTP servers cannot adequately handle command pipelining.
  32. Flaws known to exist in deployed servers include:
  33. (1) Connection handoff and buffer flushes in the middle of
  34. the SMTP dialogue. Creation of server processes for
  35. incoming SMTP connections is a useful, obvious, and
  36. harmless implementation technique. However, some SMTP
  37. servers defer process forking and connection handoff
  38. Freed & Cargille Standards Track [Page 1]
  39. RFC 1854 SMTP Pipelining October 1995
  40. until some intermediate point in the SMTP dialogue.
  41. When this is done material read from the TCP connection
  42. and kept in process buffers can be lost.
  43. (2) Flushing the TCP input buffer when an SMTP command
  44. fails. SMTP commands often fail but there is no reason
  45. to flush the TCP input buffer when this happens.
  46. Nevertheless, some SMTP servers do this.
  47. (3) Improper processing and promulgation of SMTP command
  48. failures. For example, some SMTP servers will refuse to
  49. accept a DATA command if the last RCPT TO command
  50. fails, paying no attention to the success or failure of
  51. prior RCPT TO command results. Other servers will
  52. accept a DATA command even when all previous RCPT TO
  53. commands have failed. Although it is possible to
  54. accommodate this sort of behavior in a client that
  55. employs command pipelining, it does complicate the
  56. construction of the client unnecessarily.
  57. This memo uses the mechanism described in [2] to define an extension
  58. to the SMTP service whereby an SMTP server can declare that it is
  59. capable of handling pipelined commands. The SMTP client can then
  60. check for this declaration and use pipelining only when the server
  61. declares itself capable of handling it.
  62. 1. Framework for the Command Pipelining Extension
  63. The Command Pipelining extension is defined as follows:
  64. (1) the name of the SMTP service extension is Pipelining;
  65. (2) the EHLO keyword value associated with the extension is
  66. PIPELINING;
  67. (3) no parameter is used with the PIPELINING EHLO keyword;
  68. (4) no additional parameters are added to either the MAIL
  69. FROM or RCPT TO commands.
  70. (5) no additional SMTP verbs are defined by this extension;
  71. and,
  72. (6) the next section specifies how support for the
  73. extension affects the behavior of a server and client
  74. SMTP.
  75. Freed & Cargille Standards Track [Page 2]
  76. RFC 1854 SMTP Pipelining October 1995
  77. 2. The Pipelining Service Extension
  78. When a client SMTP wishes to employ command pipelining, it first
  79. issues the EHLO command to the server SMTP. If the server SMTP
  80. responds with code 250 to the EHLO command, and the response includes
  81. the EHLO keyword value PIPELINING, then the server SMTP has indicated
  82. that it can accommodate SMTP command pipelining.
  83. 2.1. Client use of pipelining
  84. Once the client SMTP has confirmed that support exists for the
  85. pipelining extension, the client SMTP may then elect to transmit
  86. groups of SMTP commands in batches without waiting for a response to
  87. each individual command. In particular, the commands RSET, MAIL FROM,
  88. SEND FROM, SOML FROM, SAML FROM, and RCPT TO can all appear anywhere
  89. in a pipelined command group. The EHLO, DATA, VRFY, EXPN, TURN,
  90. QUIT, and NOOP commands can only appear as the last command in a
  91. group since their success or failure produces a change of state which
  92. the client SMTP must accommodate. (NOOP is included in this group so
  93. it can be used as a synchronization point.)
  94. Additional commands added by other SMTP extensions may only appear as
  95. the last command in a group unless otherwise specified by the
  96. extensions that define the commands.
  97. The actual transfer of message content is explicitly allowed to be
  98. the first "command" in a group. That is, the RSET/MAIL FROM sequence
  99. necessary to initiate a new message transaction can be placed in the
  100. same group as the final transfer of the headers and body of the
  101. previous message.
  102. Client SMTP implementations that employ pipelining MUST check ALL
  103. statuses associated with each command in a group. For example, if
  104. none of the RCPT TO recipient addresses were accepted the client must
  105. then check the response to the DATA command -- the client cannot
  106. assume that the DATA command will be rejected just because none of
  107. the RCPT TO commands worked. If the DATA command was properly
  108. rejected the client SMTP can just issue RSET, but if the DATA command
  109. was accepted the client SMTP should send a single dot.
  110. Command statuses MUST be coordinated with responses by counting each
  111. separate response and correlating that count with the number of
  112. commands known to have been issued. Multiline responses MUST be
  113. supported. Matching on the basis of either the error code value or
  114. associated text is expressly forbidden.
  115. Client SMTP implementations MAY elect to operate in a nonblocking
  116. fashion, processing server responses immediately upon receipt, even
  117. Freed & Cargille Standards Track [Page 3]
  118. RFC 1854 SMTP Pipelining October 1995
  119. if there is still data pending transmission from the client's
  120. previous TCP send operation. If nonblocking operation is not
  121. supported, however, client SMTP implementations MUST also check the
  122. TCP window size and make sure that each group of commands fits
  123. entirely within the window. The window size is usually, but not
  124. always, 4K octets. Failure to perform this check can lead to
  125. deadlock conditions.
  126. Clients MUST NOT confuse responses to multiple commands with
  127. multiline responses. Each command requires one or more lines of
  128. response, the last line not containing a dash between the response
  129. code and the response string.
  130. 2.2. Server support of pipelining
  131. A server SMTP implementation that offers the pipelining extension:
  132. (1) MUST NOT flush or otherwise lose the contents of the
  133. TCP input buffer under any circumstances whatsoever.
  134. (2) SHOULD issue a positive response to the DATA command if
  135. and only if one or more valid RCPT TO addresses have
  136. been previously received.
  137. (3) MUST NOT, after issuing a positive response to a DATA
  138. command with no valid recipients and subsequently
  139. receiving an empty message, send any message whatsoever
  140. to anybody.
  141. (4) SHOULD elect to store responses to grouped RSET, MAIL
  142. FROM, SEND FROM, SOML FROM, SAML FROM, and RCPT TO
  143. commands in an internal buffer so they can sent as a
  144. unit.
  145. (5) MUST NOT buffer responses to EHLO, DATA, VRFY, EXPN,
  146. TURN, QUIT, and NOOP.
  147. (6) MUST NOT buffer responses to unrecognized commands.
  148. (7) MUST send all pending responses immediately whenever
  149. the local TCP input buffer is emptied.
  150. (8) MUST NOT make assumptions about commands that are yet
  151. to be received.
  152. (9) SHOULD issue response text that indicates, either
  153. implicitly or explicitly, what command the response
  154. matches.
  155. Freed & Cargille Standards Track [Page 4]
  156. RFC 1854 SMTP Pipelining October 1995
  157. The overriding intent of these server requirements is to make it as
  158. easy as possible for servers to conform to these pipelining
  159. extensions.
  160. 3. Examples
  161. Consider the following SMTP dialogue that does not use pipelining:
  162. S: <wait for open connection>
  163. C: <open connection to server>
  164. S: 220 innosoft.com SMTP service ready
  165. C: HELO dbc.mtview.ca.us
  166. S: 250 innosoft.com
  167. C: MAIL FROM:<mrose@dbc.mtview.ca.us>
  168. S: 250 sender <mrose@dbc.mtview.ca.us> OK
  169. C: RCPT TO:<ned@innosoft.com>
  170. S: 250 recipient <ned@innosoft.com> OK
  171. C: RCPT TO:<dan@innosoft.com>
  172. S: 250 recipient <dan@innosoft.com> OK
  173. C: RCPT TO:<kvc@innosoft.com>
  174. S: 250 recipient <kvc@innosoft.com> OK
  175. C: DATA
  176. S: 354 enter mail, end with line containing only "."
  177. ...
  178. C: .
  179. S: 250 message sent
  180. C: QUIT
  181. S: 221 goodbye
  182. The client waits for a server response a total of 9 times in this
  183. simple example. But if pipelining is employed the following dialogue
  184. is possible:
  185. S: <wait for open connection>
  186. C: <open connection to server>
  187. S: 220 innosoft.com SMTP service ready
  188. C: EHLO dbc.mtview.ca.us
  189. S: 250-innosoft.com
  190. S: 250 PIPELINING
  191. C: MAIL FROM:<mrose@dbc.mtview.ca.us>
  192. C: RCPT TO:<ned@innosoft.com>
  193. C: RCPT TO:<dan@innosoft.com>
  194. C: RCPT TO:<kvc@innosoft.com>
  195. C: DATA
  196. S: 250 sender <mrose@dbc.mtview.ca.us> OK
  197. S: 250 recipient <ned@innosoft.com> OK
  198. S: 250 recipient <dan@innosoft.com> OK
  199. S: 250 recipient <kvc@innosoft.com> OK
  200. Freed & Cargille Standards Track [Page 5]
  201. RFC 1854 SMTP Pipelining October 1995
  202. S: 354 enter mail, end with line containing only "."
  203. ...
  204. C: .
  205. C: QUIT
  206. S: 250 message sent
  207. S: 221 goodbye
  208. The total number of turnarounds has been reduced from 9 to 4.
  209. The next example illustrates one possible form of behavior when
  210. pipelining is used and all recipients are rejected:
  211. S: <wait for open connection>
  212. C: <open connection to server>
  213. S: 220 innosoft.com SMTP service ready
  214. C: EHLO dbc.mtview.ca.us
  215. S: 250-innosoft.com
  216. S: 250 PIPELINING
  217. C: MAIL FROM:<mrose@dbc.mtview.ca.us>
  218. C: RCPT TO:<nsb@thumper.bellcore.com>
  219. C: RCPT TO:<galvin@tis.com>
  220. C: DATA
  221. S: 250 sender <mrose@dbc.mtview.ca.us> OK
  222. S: 550 remote mail to <nsb@thumper.bellore.com> not allowed
  223. S: 550 remote mail to <galvin@tis.com> not allowed
  224. S: 554 no valid recipients given
  225. C: QUIT
  226. S: 221 goodbye
  227. The client SMTP waits for the server 4 times here as well. If the
  228. server SMTP does not check for at least one valid recipient prior to
  229. accepting the DATA command, the following dialogue would result:
  230. S: <wait for open connection>
  231. C: <open connection to server>
  232. S: 220 innosoft.com SMTP service ready
  233. C: EHLO dbc.mtview.ca.us
  234. S: 250-innosoft.com
  235. S: 250 PIPELINING
  236. C: MAIL FROM:<mrose@dbc.mtview.ca.us>
  237. C: RCPT TO:<nsb@thumper.bellcore.com>
  238. C: RCPT TO:<galvin@tis.com>
  239. C: DATA
  240. S: 250 sender <mrose@dbc.mtview.ca.us> OK
  241. S: 550 remote mail to <nsb@thumper.bellore.com> not allowed
  242. S: 550 remote mail to <galvin@tis.com> not allowed
  243. S: 354 enter mail, end with line containing only "."
  244. C: .
  245. Freed & Cargille Standards Track [Page 6]
  246. RFC 1854 SMTP Pipelining October 1995
  247. C: QUIT
  248. S: 554 no valid recipients
  249. S: 221 goodbye
  250. 4. Security Considerations
  251. This RFC does not discuss security issues and is not believed to
  252. raise any security issues not endemic in electronic mail and present
  253. in fully conforming implementations of [1].
  254. 5. Acknowledgements
  255. This document is based on the SMTP service extension model presented
  256. in RFC 1425. Marshall Rose's description of SMTP command pipelining
  257. in his book "The Internet Message" also served as a source of
  258. inspiration for this extension.
  259. 6. References
  260. [1] Postel, J., "Simple Mail Transfer Protocol", STD 10
  261. RFC 821, USC/Information Sciences Institute, August
  262. 1982.
  263. [2] Klensin, J., Freed, N., Rose, M., Stefferud, E.,
  264. and D. Crocker, "SMTP Service Extensions", RFC 1651,
  265. MCI, Innosoft, Dover Beach Consulting, Inc.,
  266. Network Management Associates, Inc., Silicon Graphics,
  267. Inc., July 1994.
  268. 7. Author's Address
  269. Ned Freed
  270. Innosoft International, Inc.
  271. 1050 East Garvey Avenue South
  272. West Covina, CA 91790
  273. USA
  274. Phone: +1 818 919 3600
  275. Fax: +1 818 919 3614
  276. EMail: ned@innosoft.com
  277. Freed & Cargille Standards Track [Page 7]