idnits 2.17.1 draft-klensin-rfc5321bis-02.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** The abstract seems to contain references ([5321bis]), which it shouldn't. Please replace those with straight textual mentions of the documents in question. == There are 2 instances of lines with non-RFC2606-compliant FQDNs in the document. -- The draft header indicates that this document obsoletes RFC5321, but the abstract doesn't seem to directly say this. It does mention RFC5321 though, so this could be OK. -- The draft header indicates that this document obsoletes RFC7504, but the abstract doesn't seem to mention this, which it should. -- The draft header indicates that this document obsoletes RFC1846, but the abstract doesn't seem to mention this, which it should. -- The draft header indicates that this document updates RFC1123, but the abstract doesn't seem to mention this, which it should. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == Using lowercase 'not' together with uppercase 'MUST', 'SHALL', 'SHOULD', or 'RECOMMENDED' is not an accepted usage according to RFC 2119. Please use uppercase 'NOT' together with RFC 2119 keywords (if that is what you mean). Found 'SHOULD not' in this paragraph: When an SMTP server returns a permanent error status (5yz) code after the DATA command is completed with ., it MUST NOT make any subsequent attempt to deliver the message. As with temporary error status codes, the SMTP client retains responsibility for the message, but SHOULD not again attempt delivery to the same server without user review of the message and response and appropriate intervention. (Using the creation date from RFC1123, updated by this document, for RFC5378 checks: 1989-10-01) -- The document seems to lack a disclaimer for pre-RFC5378 work, but may have content which was first submitted before 10 November 2008. If you have contacted all the original authors and they are all willing to grant the BCP78 rights to the IETF Trust, then this is fine, and you can ignore this comment. If not, you may need to add the pre-RFC5378 disclaimer. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (December 27, 2019) is 1581 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Looks like a reference, but probably isn't: '5321bis' on line 4456 -- Possible downref: Non-RFC (?) normative reference: ref. '2' ** Obsolete normative reference: RFC 821 (ref. '8') (Obsoleted by RFC 2821) -- Obsolete informational reference (is this intentional?): RFC 822 (ref. '16') (Obsoleted by RFC 2822) -- Obsolete informational reference (is this intentional?): RFC 974 (ref. '19') (Obsoleted by RFC 2821) -- Obsolete informational reference (is this intentional?): RFC 1652 (ref. '23') (Obsoleted by RFC 6152) -- Obsolete informational reference (is this intentional?): RFC 1869 (ref. '26') (Obsoleted by RFC 2821) -- Obsolete informational reference (is this intentional?): RFC 2821 (ref. '34') (Obsoleted by RFC 5321) -- Obsolete informational reference (is this intentional?): RFC 3501 (ref. '39') (Obsoleted by RFC 9051) -- Obsolete informational reference (is this intentional?): RFC 3798 (ref. '40') (Obsoleted by RFC 8098) -- Obsolete informational reference (is this intentional?): RFC 3851 (ref. '41') (Obsoleted by RFC 5751) -- Obsolete informational reference (is this intentional?): RFC 4408 (ref. '42') (Obsoleted by RFC 7208) -- Obsolete informational reference (is this intentional?): RFC 4409 (ref. '43') (Obsoleted by RFC 6409) -- Obsolete informational reference (is this intentional?): RFC 4871 (ref. '45') (Obsoleted by RFC 6376) Summary: 2 errors (**), 0 flaws (~~), 3 warnings (==), 19 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group J. Klensin 3 Internet-Draft December 27, 2019 4 Obsoletes: 5321, 1846, 7504 (if 5 approved) 6 Updates: 1123 (if approved) 7 Intended status: Standards Track 8 Expires: June 29, 2020 10 Simple Mail Transfer Protocol 11 draft-klensin-rfc5321bis-02 13 Abstract 15 This document is a specification of the basic protocol for Internet 16 electronic mail transport. It consolidates, updates, and clarifies 17 several previous documents, making all or parts of most of them 18 obsolete. It covers the SMTP extension mechanisms and best practices 19 for the contemporary Internet, but does not provide details about 20 particular extensions. Although SMTP was designed as a mail 21 transport and delivery protocol, this specification also contains 22 information that is important to its use as a "mail submission" 23 protocol for "split-UA" (User Agent) mail reading systems and mobile 24 environments. 26 Note on Reading This Working Draft 28 This working draft is extensively annotated with information about 29 changes made over the decade since RFC 5321 appeared, especially when 30 those changes might be controversial or should get careful review. 31 Anything marked in CREF comments with "[5321bis]" is current. In 32 general, unless those are marked with "[[Note in Draft", in the 33 contents of an "Editor's note", or are in the "Errata Summary" 34 appendix (Appendix H.1, they are just notes on changes that have 35 already been made and where those changes originated. Comments 36 identified as "2821ter" arose after the Last Call on what became 37 RFC5321, sometimes before AUTH48 on that document or a bit later. 38 Those, of course, should still be reviewed. Surviving comments about 39 rfc5321bis-00 followed by a letter indicate intermediate working 40 versions of this draft and can be ignored unless the origin of 41 changes is important. As one can tell from the dates (when they are 42 given), this document has been periodically updated over a very long 43 period of time. 45 This evolving draft should be discussed on the ietf-smtp@ietf.org 46 list. 48 Status of This Memo 50 This Internet-Draft is submitted in full conformance with the 51 provisions of BCP 78 and BCP 79. 53 Internet-Drafts are working documents of the Internet Engineering 54 Task Force (IETF). Note that other groups may also distribute 55 working documents as Internet-Drafts. The list of current Internet- 56 Drafts is at https://datatracker.ietf.org/drafts/current/. 58 Internet-Drafts are draft documents valid for a maximum of six months 59 and may be updated, replaced, or obsoleted by other documents at any 60 time. It is inappropriate to use Internet-Drafts as reference 61 material or to cite them other than as "work in progress." 63 This Internet-Draft will expire on June 29, 2020. 65 Copyright Notice 67 Copyright (c) 2019 IETF Trust and the persons identified as the 68 document authors. All rights reserved. 70 This document is subject to BCP 78 and the IETF Trust's Legal 71 Provisions Relating to IETF Documents 72 (https://trustee.ietf.org/license-info) in effect on the date of 73 publication of this document. Please review these documents 74 carefully, as they describe your rights and restrictions with respect 75 to this document. Code Components extracted from this document must 76 include Simplified BSD License text as described in Section 4.e of 77 the Trust Legal Provisions and are provided without warranty as 78 described in the Simplified BSD License. 80 Table of Contents 82 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 5 83 1.1. Transport of Electronic Mail . . . . . . . . . . . . . . 5 84 1.2. History and Context for This Document . . . . . . . . . . 6 85 1.3. Document Conventions . . . . . . . . . . . . . . . . . . 7 86 2. The SMTP Model . . . . . . . . . . . . . . . . . . . . . . . 7 87 2.1. Basic Structure . . . . . . . . . . . . . . . . . . . . . 8 88 2.2. The Extension Model . . . . . . . . . . . . . . . . . . . 10 89 2.2.1. Background . . . . . . . . . . . . . . . . . . . . . 10 90 2.2.2. Definition and Registration of Extensions . . . . . . 11 91 2.2.3. Special Issues with Extensions . . . . . . . . . . . 12 92 2.3. SMTP Terminology . . . . . . . . . . . . . . . . . . . . 12 93 2.3.1. Mail Objects . . . . . . . . . . . . . . . . . . . . 12 94 2.3.2. Senders and Receivers . . . . . . . . . . . . . . . . 13 95 2.3.3. Mail Agents and Message Stores . . . . . . . . . . . 13 96 2.3.4. Host . . . . . . . . . . . . . . . . . . . . . . . . 13 97 2.3.5. Domain Names . . . . . . . . . . . . . . . . . . . . 14 98 2.3.6. Buffer and State Table . . . . . . . . . . . . . . . 15 99 2.3.7. Commands and Replies . . . . . . . . . . . . . . . . 15 100 2.3.8. Lines . . . . . . . . . . . . . . . . . . . . . . . . 15 101 2.3.9. Message Content and Mail Data . . . . . . . . . . . . 16 102 2.3.10. Originator, Delivery, Relay, and Gateway Systems . . 16 103 2.3.11. Mailbox and Address . . . . . . . . . . . . . . . . . 16 104 2.4. General Syntax Principles and Transaction Model . . . . . 17 105 3. The SMTP Procedures: An Overview . . . . . . . . . . . . . . 18 106 3.1. Session Initiation . . . . . . . . . . . . . . . . . . . 19 107 3.2. Client Initiation . . . . . . . . . . . . . . . . . . . . 19 108 3.3. Mail Transactions . . . . . . . . . . . . . . . . . . . . 20 109 3.4. Forwarding for Address Correction or Updating . . . . . . 22 110 3.5. Commands for Debugging Addresses . . . . . . . . . . . . 23 111 3.5.1. Overview . . . . . . . . . . . . . . . . . . . . . . 23 112 3.5.2. VRFY Normal Response . . . . . . . . . . . . . . . . 25 113 3.5.3. Meaning of VRFY or EXPN Success Response . . . . . . 26 114 3.5.4. Semantics and Applications of EXPN . . . . . . . . . 27 115 3.6. Relaying and Mail Routing . . . . . . . . . . . . . . . . 27 116 3.6.1. Source Routes and Relaying . . . . . . . . . . . . . 27 117 3.6.2. Mail eXchange Records and Relaying . . . . . . . . . 27 118 3.6.3. Message Submission Servers as Relays . . . . . . . . 28 119 3.7. Mail Gatewaying . . . . . . . . . . . . . . . . . . . . . 29 120 3.7.1. Header Fields in Gatewaying . . . . . . . . . . . . . 29 121 3.7.2. Received Lines in Gatewaying . . . . . . . . . . . . 30 122 3.7.3. Addresses in Gatewaying . . . . . . . . . . . . . . . 30 123 3.7.4. Other Header Fields in Gatewaying . . . . . . . . . . 30 124 3.7.5. Envelopes in Gatewaying . . . . . . . . . . . . . . . 31 125 3.8. Terminating Sessions and Connections . . . . . . . . . . 31 126 3.9. Mailing Lists and Aliases . . . . . . . . . . . . . . . . 32 127 3.9.1. Alias . . . . . . . . . . . . . . . . . . . . . . . . 32 128 3.9.2. List . . . . . . . . . . . . . . . . . . . . . . . . 32 129 4. The SMTP Specifications . . . . . . . . . . . . . . . . . . . 33 130 4.1. SMTP Commands . . . . . . . . . . . . . . . . . . . . . . 33 131 4.1.1. Command Semantics and Syntax . . . . . . . . . . . . 33 132 4.1.2. Command Argument Syntax . . . . . . . . . . . . . . . 41 133 4.1.3. Address Literals . . . . . . . . . . . . . . . . . . 44 134 4.1.4. Order of Commands . . . . . . . . . . . . . . . . . . 45 135 4.1.5. Private-Use Commands . . . . . . . . . . . . . . . . 47 136 4.2. SMTP Replies . . . . . . . . . . . . . . . . . . . . . . 47 137 4.2.1. Reply Code Severities and Theory . . . . . . . . . . 49 138 4.2.2. Reply Codes by Function Groups . . . . . . . . . . . 51 139 4.2.3. Reply Codes in Numeric Order . . . . . . . . . . . . 53 140 4.2.4. Some specific code situations and relationships . . . 54 141 4.3. Sequencing of Commands and Replies . . . . . . . . . . . 56 142 4.3.1. Sequencing Overview . . . . . . . . . . . . . . . . . 56 143 4.3.2. Command-Reply Sequences . . . . . . . . . . . . . . . 57 145 4.4. Trace Information . . . . . . . . . . . . . . . . . . . . 59 146 4.5. Additional Implementation Issues . . . . . . . . . . . . 63 147 4.5.1. Minimum Implementation . . . . . . . . . . . . . . . 63 148 4.5.2. Transparency . . . . . . . . . . . . . . . . . . . . 64 149 4.5.3. Sizes and Timeouts . . . . . . . . . . . . . . . . . 64 150 4.5.4. Retry Strategies . . . . . . . . . . . . . . . . . . 68 151 4.5.5. Messages with a Null Reverse-Path . . . . . . . . . . 70 152 5. Address Resolution and Mail Handling . . . . . . . . . . . . 71 153 5.1. Locating the Target Host . . . . . . . . . . . . . . . . 71 154 5.2. IPv6 and MX Records . . . . . . . . . . . . . . . . . . . 73 155 6. Problem Detection and Handling . . . . . . . . . . . . . . . 74 156 6.1. Reliable Delivery and Replies by Email . . . . . . . . . 74 157 6.2. Unwanted, Unsolicited, and "Attack" Messages . . . . . . 75 158 6.3. Loop Detection . . . . . . . . . . . . . . . . . . . . . 76 159 6.4. Compensating for Irregularities . . . . . . . . . . . . . 76 160 7. Security Considerations . . . . . . . . . . . . . . . . . . . 77 161 7.1. Mail Security and Spoofing . . . . . . . . . . . . . . . 77 162 7.2. "Blind" Copies . . . . . . . . . . . . . . . . . . . . . 78 163 7.3. VRFY, EXPN, and Security . . . . . . . . . . . . . . . . 79 164 7.4. Mail Rerouting Based on the 251 and 551 Response 165 Codes . . . . . . . . . . . . . . . . . . . . . . . . . . 80 166 7.5. Information Disclosure in Announcements . . . . . . . . . 80 167 7.6. Information Disclosure in Trace Fields . . . . . . . . . 80 168 7.7. Information Disclosure in Message Forwarding . . . . . . 80 169 7.8. Resistance to Attacks . . . . . . . . . . . . . . . . . . 81 170 7.9. Scope of Operation of SMTP Servers . . . . . . . . . . . 81 171 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 81 172 9. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 83 173 10. References . . . . . . . . . . . . . . . . . . . . . . . . . 83 174 10.1. Normative References . . . . . . . . . . . . . . . . . . 83 175 10.2. Informative References . . . . . . . . . . . . . . . . . 84 176 Appendix A. TCP Transport Service . . . . . . . . . . . . . . . 89 177 Appendix B. Generating SMTP Commands from RFC 822 Header Fields 89 178 Appendix C. Source Routes . . . . . . . . . . . . . . . . . . . 90 179 Appendix D. Scenarios . . . . . . . . . . . . . . . . . . . . . 91 180 D.1. A Typical SMTP Transaction Scenario . . . . . . . . . . . 91 181 D.2. Aborted SMTP Transaction Scenario . . . . . . . . . . . . 92 182 D.3. Relayed Mail Scenario . . . . . . . . . . . . . . . . . . 93 183 D.4. Verifying and Sending Scenario . . . . . . . . . . . . . 94 184 Appendix E. Other Gateway Issues . . . . . . . . . . . . . . . . 95 185 Appendix F. Deprecated Features of RFC 821 . . . . . . . . . . . 95 186 F.1. TURN . . . . . . . . . . . . . . . . . . . . . . . . . . 95 187 F.2. Source Routing . . . . . . . . . . . . . . . . . . . . . 95 188 F.3. HELO . . . . . . . . . . . . . . . . . . . . . . . . . . 96 189 F.4. #-literals . . . . . . . . . . . . . . . . . . . . . . . 96 190 F.5. Dates and Years . . . . . . . . . . . . . . . . . . . . . 96 191 F.6. Sending versus Mailing . . . . . . . . . . . . . . . . . 96 192 Appendix G. Other Outstanding Issues . . . . . . . . . . . . . . 97 193 G.1. IP Address Literals . . . . . . . . . . . . . . . . . . . 98 194 G.2. Repeated Use of EHLO . . . . . . . . . . . . . . . . . . 98 195 G.3. Meaning of "MTA" and Related Terminology . . . . . . . . 98 196 G.4. Originator, or Originating System, Authentication . . . . 98 197 G.5. Remove or deprecate the work-around from code 552 to 452 99 198 G.6. Clarify where the protocol stands with respect to 199 submission and TLS issues . . . . . . . . . . . . . . . . 99 200 G.7. Probably-substantive Discussion Topics Identified in 201 Other Ways . . . . . . . . . . . . . . . . . . . . . . . 99 202 G.7.1. Issues with 521, 554, and 556 codes . . . . . . . . . 99 203 G.7.2. SMTP Model, terminology, and relationship to RFC 5598 99 204 G.7.3. Resolvable FQDNs and private domain names . . . . . . 99 205 G.7.4. Possible clarification about mail transactions and 206 transaction state . . . . . . . . . . . . . . . . . . 99 207 G.7.5. Issues with mailing lists, aliases, and forwarding . 99 208 G.7.6. Requirements for domain name and/or IP address in 209 EHLO . . . . . . . . . . . . . . . . . . . . . . . . 99 210 G.7.7. Does the 'first digit only' and/or non-listed reply 211 code text need clarification? . . . . . . . . . . . . 100 212 G.7.8. Size limits . . . . . . . . . . . . . . . . . . . . . 100 213 G.7.9. Discussion of 'blind' copies and RCPT . . . . . . . . 100 214 G.7.10. Further clarifications needed to source routes? . . . 100 215 Appendix H. Change log for RFC 5321bis . . . . . . . . . . . . . 100 216 H.1. RFC 5321 Errata Summary . . . . . . . . . . . . . . . . . 100 217 H.2. Changes from RFC 5321 (published October 2008) to the 218 initial (-00) version of this draft . . . . . . . . . . . 101 219 H.3. Changes Among Versions of Rfc5321bis . . . . . . . . . . 103 220 H.3.1. Changes from draft-klensin-rfc5321bis-00 (posted 221 2012-12-02) to -01 . . . . . . . . . . . . . . . . . 103 222 H.3.2. Changes from draft-klensin-rfc5321bis-01 (20191203) 223 to -02 . . . . . . . . . . . . . . . . . . . . . . . 103 224 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 225 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 105 227 1. Introduction 229 1.1. Transport of Electronic Mail 231 The objective of the Simple Mail Transfer Protocol (SMTP) is to 232 transfer mail reliably and efficiently. 234 SMTP is independent of the particular transmission subsystem and 235 requires only a reliable ordered data stream channel. While this 236 document specifically discusses transport over TCP, other transports 237 are possible. Appendices to RFC 821 [8] describe some of them. 239 An important feature of SMTP is its capability to transport mail 240 across multiple networks, usually referred to as "SMTP mail relaying" 241 (see Section 3.6). A network consists of the mutually-TCP-accessible 242 hosts on the public Internet, the mutually-TCP-accessible hosts on a 243 firewall-isolated TCP/IP Intranet, or hosts in some other LAN or WAN 244 environment utilizing a non-TCP transport-level protocol. Using 245 SMTP, a process can transfer mail to another process on the same 246 network or to some other network via a relay or gateway process 247 accessible to both networks. 249 In this way, a mail message may pass through a number of intermediate 250 relay or gateway hosts on its path from sender to ultimate recipient. 251 The Mail eXchanger mechanisms of the domain name system (RFC 1035 252 [7], RFC 974 [19], and Section 5 of this document) are used to 253 identify the appropriate next-hop destination for a message being 254 transported. 256 1.2. History and Context for This Document 258 This document is a specification of the basic protocol for the 259 Internet electronic mail transport. It consolidates, updates and 260 clarifies, but does not add new or change existing functionality of 261 the following: 263 o the original SMTP (Simple Mail Transfer Protocol) specification of 264 RFC 821 [8], 266 o domain name system requirements and implications for mail 267 transport from RFC 1035 [7] and RFC 974 [19], 269 o the clarifications and applicability statements in RFC 1123 [3], 271 o the new error codes added by RFC 1846 [24] and later by RFC 7504> 272 [48], obsoleting both of those documents, and 274 o material drawn from the SMTP Extension mechanisms in RFC 1869 275 [26]. 277 o Editorial and clarification changes to RFC 2821 [34] to bring that 278 specification to Draft Standard. 280 It obsoletes RFC 821, RFC 974, RFC 1869, and RFC 2821 and updates RFC 281 1123 (replacing the mail transport materials of RFC 1123). However, 282 RFC 821 specifies some features that were not in significant use in 283 the Internet by the mid-1990s and (in appendices) some additional 284 transport models. Those sections are omitted here in the interest of 285 clarity and brevity; readers needing them should refer to RFC 821. 287 It also includes some additional material from RFC 1123 that required 288 amplification. This material has been identified in multiple ways, 289 mostly by tracking flaming on various lists and newsgroups and 290 problems of unusual readings or interpretations that have appeared as 291 the SMTP extensions have been deployed. Where this specification 292 moves beyond consolidation and actually differs from earlier 293 documents, it supersedes them technically as well as textually. 295 Although SMTP was designed as a mail transport and delivery protocol, 296 this specification also contains information that is important to its 297 use as a "mail submission" protocol, as recommended for Post Office 298 Protocol (POP) (RFC 937 [17], RFC 1939 [27]) and IMAP (RFC 3501 299 [39]). In general, the separate mail submission protocol specified 300 in RFC 4409 [43] is now preferred to direct use of SMTP; more 301 discussion of that subject appears in that document. 303 Section 2.3 provides definitions of terms specific to this document. 304 Except when the historical terminology is necessary for clarity, this 305 document uses the current 'client' and 'server' terminology to 306 identify the sending and receiving SMTP processes, respectively. 308 A companion document, RFC 5322 [11], discusses message header 309 sections and bodies and specifies formats and structures for them. 311 1.3. Document Conventions 313 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 314 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 315 document are to be interpreted as described in RFC 2119 [1]. As each 316 of these terms was intentionally and carefully chosen to improve the 317 interoperability of email, each use of these terms is to be treated 318 as a conformance requirement. 320 Because this document has a long history and to avoid the risk of 321 various errors and of confusing readers and documents that point to 322 this one, most examples and the domain names they contain are 323 preserved from RFC 2821. Readers are cautioned that these are 324 illustrative examples that should not actually be used in either code 325 or configuration files. 327 2. The SMTP Model 329 [[CREF1: [5321bis] [[Editor's Note: There have been extensive and 330 repeated discussions on the SMTP and IETF lists about whether this 331 document should say something about hop-by-hop (MTA-to-MTA) SMTP 332 authentication and, if so, what?? Note that end to end message 333 authentication is almost certainly out of scope for SMTP.]]]] 335 2.1. Basic Structure 337 The SMTP design can be pictured as: 339 +----------+ +----------+ 340 +------+ | | | | 341 | User |<-->| | SMTP | | 342 +------+ | Client- |Commands/Replies| Server- | 343 +------+ | SMTP |<-------------->| SMTP | +------+ 344 | File |<-->| | and Mail | |<-->| File | 345 |System| | | | | |System| 346 +------+ +----------+ +----------+ +------+ 347 SMTP client SMTP server 349 When an SMTP client has a message to transmit, it establishes a two- 350 way transmission channel to an SMTP server. The responsibility of an 351 SMTP client is to transfer mail messages to one or more SMTP servers, 352 or report its failure to do so. 354 The means by which a mail message is presented to an SMTP client, and 355 how that client determines the identifier(s) ("names") of the 356 domain(s) to which mail messages are to be transferred, are local 357 matters. They are not addressed by this document. In some cases, 358 the designated domain(s), or those determined by an SMTP client, will 359 identify the final destination(s) of the mail message. In other 360 cases, common with SMTP clients associated with implementations of 361 the POP (RFC 937 [17], RFC 1939 [27]) or IMAP (RFC 3501 [39]) 362 protocols, or when the SMTP client is inside an isolated transport 363 service environment, the domain determined will identify an 364 intermediate destination through which all mail messages are to be 365 relayed. SMTP clients that transfer all traffic regardless of the 366 target domains associated with the individual messages, or that do 367 not maintain queues for retrying message transmissions that initially 368 cannot be completed, may otherwise conform to this specification but 369 are not considered fully-capable. Fully-capable SMTP 370 implementations, including the relays used by these less capable 371 ones, and their destinations, are expected to support all of the 372 queuing, retrying, and alternate address functions discussed in this 373 specification. In many situations and configurations, the less- 374 capable clients discussed above SHOULD be using the message 375 submission protocol (RFC 4409 [43]) rather than SMTP. 377 The means by which an SMTP client, once it has determined a target 378 domain, determines the identity of an SMTP server to which a copy of 379 a message is to be transferred, and then performs that transfer, are 380 covered by this document. To effect a mail transfer to an SMTP 381 server, an SMTP client establishes a two-way transmission channel to 382 that SMTP server. An SMTP client determines the address of an 383 appropriate host running an SMTP server by resolving a destination 384 domain name to either an intermediate Mail eXchanger host or a final 385 target host. 387 An SMTP server may be either the ultimate destination or an 388 intermediate "relay" (that is, it may assume the role of an SMTP 389 client after receiving the message) or "gateway" (that is, it may 390 transport the message further using some protocol other than SMTP). 391 SMTP commands are generated by the SMTP client and sent to the SMTP 392 server. SMTP replies are sent from the SMTP server to the SMTP 393 client in response to the commands. 395 In other words, message transfer can occur in a single connection 396 between the original SMTP-sender and the final SMTP-recipient, or can 397 occur in a series of hops through intermediary systems. In either 398 case, once the server has issued a success response at the end of the 399 mail data, a formal handoff of responsibility for the message occurs: 400 the protocol requires that a server MUST accept responsibility for 401 either delivering the message or properly reporting the failure to do 402 so (see Sections 6.1, 6.2, and 7.8, below). 404 Once the transmission channel is established and initial handshaking 405 is completed, the SMTP client normally initiates a mail transaction. 406 Such a transaction consists of a series of commands to specify the 407 originator and destination of the mail and transmission of the 408 message content (including any lines in the header section or other 409 structure) itself. When the same message is sent to multiple 410 recipients, this protocol encourages the transmission of only one 411 copy of the data for all recipients at the same destination (or 412 intermediate relay) host. 414 The server responds to each command with a reply; replies may 415 indicate that the command was accepted, that additional commands are 416 expected, or that a temporary or permanent error condition exists. 417 Commands specifying the sender or recipients may include server- 418 permitted SMTP service extension requests, as discussed in 419 Section 2.2. The dialog is purposely lock-step, one-at-a-time, 420 although this can be modified by mutually agreed upon extension 421 requests such as command pipelining (RFC 2920 [35]). 423 Once a given mail message has been transmitted, the client may either 424 request that the connection be shut down or may initiate other mail 425 transactions. In addition, an SMTP client may use a connection to an 426 SMTP server for ancillary services such as verification of email 427 addresses or retrieval of mailing list subscriber addresses. 429 As suggested above, this protocol provides mechanisms for the 430 transmission of mail. Historically, this transmission normally 431 occurred directly from the sending user's host to the receiving 432 user's host when the two hosts are connected to the same transport 433 service. When they are not connected to the same transport service, 434 transmission occurs via one or more relay SMTP servers. A very 435 common case in the Internet today involves submission of the original 436 message to an intermediate, "message submission" server, which is 437 similar to a relay but has some additional properties; such servers 438 are discussed in Section 2.3.10 and at some length in RFC 4409 [43]. 439 An intermediate host that acts as either an SMTP relay or as a 440 gateway into some other transmission environment is usually selected 441 through the use of the domain name service (DNS) Mail eXchanger 442 mechanism. Explicit "source" routing (see Section 5 and Appendix C 443 and Appendix F.2) SHOULD NOT be used. [[CREF2: [5321bis] JcK 444 20090123 - redundant sentence removed.]] 446 2.2. The Extension Model 448 2.2.1. Background 450 In an effort that started in 1990, approximately a decade after RFC 451 821 was completed, the protocol was modified with a "service 452 extensions" model that permits the client and server to agree to 453 utilize shared functionality beyond the original SMTP requirements. 454 The SMTP extension mechanism defines a means whereby an extended SMTP 455 client and server may recognize each other, and the server can inform 456 the client as to the service extensions that it supports. 458 Contemporary SMTP implementations MUST support the basic extension 459 mechanisms. For instance, servers MUST support the EHLO command even 460 if they do not implement any specific extensions and clients SHOULD 461 preferentially utilize EHLO rather than HELO. (However, for 462 compatibility with older conforming implementations, SMTP clients and 463 servers MUST support the original HELO mechanisms as a fallback.) 464 Unless the different characteristics of HELO must be identified for 465 interoperability purposes, this document discusses only EHLO. 467 SMTP is widely deployed and high-quality implementations have proven 468 to be very robust. However, the Internet community now considers 469 some services to be important that were not anticipated when the 470 protocol was first designed. If support for those services is to be 471 added, it must be done in a way that permits older implementations to 472 continue working acceptably. The extension framework consists of: 474 o The SMTP command EHLO, superseding the earlier HELO, 476 o a registry of SMTP service extensions, 478 o additional parameters to the SMTP MAIL and RCPT commands, and 479 o optional replacements for commands defined in this protocol, such 480 as for DATA in non-ASCII transmissions (RFC 3030 [37]). 482 SMTP's strength comes primarily from its simplicity. Experience with 483 many protocols has shown that protocols with few options tend towards 484 ubiquity, whereas protocols with many options tend towards obscurity. 486 Each and every extension, regardless of its benefits, must be 487 carefully scrutinized with respect to its implementation, deployment, 488 and interoperability costs. In many cases, the cost of extending the 489 SMTP service will likely outweigh the benefit. 491 2.2.2. Definition and Registration of Extensions 493 The IANA maintains a registry of SMTP service extensions. A 494 corresponding EHLO keyword value is associated with each extension. 495 Each service extension registered with the IANA must be defined in a 496 formal Standards-Track or IESG-approved Experimental protocol 497 document. The definition must include: 499 o the textual name of the SMTP service extension; 501 o the EHLO keyword value associated with the extension; 503 o the syntax and possible values of parameters associated with the 504 EHLO keyword value; 506 o any additional SMTP verbs associated with the extension 507 (additional verbs will usually be, but are not required to be, the 508 same as the EHLO keyword value); 510 o any new parameters the extension associates with the MAIL or RCPT 511 verbs; 513 o a description of how support for the extension affects the 514 behavior of a server and client SMTP; and 516 o the increment by which the extension is increasing the maximum 517 length of the commands MAIL and/or RCPT, over that specified in 518 this Standard. 520 In addition, any EHLO keyword value starting with an upper or lower 521 case "X" refers to a local SMTP service extension used exclusively 522 through bilateral agreement. Keywords beginning with "X" MUST NOT be 523 used in a registered service extension. Conversely, keyword values 524 presented in the EHLO response that do not begin with "X" MUST 525 correspond to a Standard, Standards-Track, or IESG-approved 526 Experimental SMTP service extension registered with IANA. A 527 conforming server MUST NOT offer non-"X"-prefixed keyword values that 528 are not described in a registered extension. 530 Additional verbs and parameter names are bound by the same rules as 531 EHLO keywords; specifically, verbs beginning with "X" are local 532 extensions that may not be registered or standardized. Conversely, 533 verbs not beginning with "X" must always be registered. 535 2.2.3. Special Issues with Extensions 537 Extensions that change fairly basic properties of SMTP operation are 538 permitted. The text in other sections of this document must be 539 understood in that context. In particular, extensions can change the 540 minimum limits specified in Section 4.5.3, can change the ASCII 541 character set requirement as mentioned above, or can introduce some 542 optional modes of message handling. 544 In particular, if an extension implies that the delivery path 545 normally supports special features of that extension, and an 546 intermediate SMTP system finds a next hop that does not support the 547 required extension, it MAY choose, based on the specific extension 548 and circumstances, to requeue the message and try later and/or try an 549 alternate MX host. If this strategy is employed, the timeout to fall 550 back to an unextended format (if one is available) SHOULD be less 551 than the normal timeout for bouncing as undeliverable (e.g., if 552 normal timeout is three days, the requeue timeout before attempting 553 to transmit the mail without the extension might be one day). 555 2.3. SMTP Terminology 557 2.3.1. Mail Objects 559 SMTP transports a mail object. A mail object contains an envelope 560 and content. 562 The SMTP envelope is sent as a series of SMTP protocol units 563 (described in Section 3). It consists of an originator address (to 564 which error reports should be directed), one or more recipient 565 addresses, and optional protocol extension material. Historically, 566 variations on the reverse-path (originator) address specification 567 command (MAIL) could be used to specify alternate delivery modes, 568 such as immediate display; those variations have now been deprecated 569 (see Appendix F and Appendix F.6). 571 The SMTP content is sent in the SMTP DATA protocol unit and has two 572 parts: the header section and the body. If the content conforms to 573 other contemporary standards, the header section consists of a 574 collection of header fields, each consisting of a header name, a 575 colon, and data, structured as in the message format specification 576 (RFC 5322 [11]); the body, if structured, is defined according to 577 MIME (RFC 2045 [29]). The content is textual in nature, expressed 578 using the US-ASCII repertoire [2]. Although SMTP extensions (such as 579 "8BITMIME", RFC 1652 [23]) may relax this restriction for the content 580 body, the content header fields are always encoded using the US-ASCII 581 repertoire. Two MIME extensions (RFC 2047 [30] and RFC 2231 [33]) 582 define an algorithm for representing header values outside the US- 583 ASCII repertoire, while still encoding them using the US-ASCII 584 repertoire. 586 2.3.2. Senders and Receivers 588 In RFC 821, the two hosts participating in an SMTP transaction were 589 described as the "SMTP-sender" and "SMTP-receiver". This document 590 has been changed to reflect current industry terminology and hence 591 refers to them as the "SMTP client" (or sometimes just "the client") 592 and "SMTP server" (or just "the server"), respectively. Since a 593 given host may act both as server and client in a relay situation, 594 "receiver" and "sender" terminology is still used where needed for 595 clarity. 597 2.3.3. Mail Agents and Message Stores 599 Additional mail system terminology became common after RFC 821 was 600 published and, where convenient, is used in this specification. In 601 particular, SMTP servers and clients provide a mail transport service 602 and therefore act as "Mail Transfer Agents" (MTAs). "Mail User 603 Agents" (MUAs or UAs) are normally thought of as the sources and 604 targets of mail. At the source, an MUA might collect mail to be 605 transmitted from a user and hand it off to an MTA; the final 606 ("delivery") MTA would be thought of as handing the mail off to an 607 MUA (or at least transferring responsibility to it, e.g., by 608 depositing the message in a "message store"). However, while these 609 terms are used with at least the appearance of great precision in 610 other environments, the implied boundaries between MUAs and MTAs 611 often do not accurately match common, and conforming, practices with 612 Internet mail. Hence, the reader should be cautious about inferring 613 the strong relationships and responsibilities that might be implied 614 if these terms were used elsewhere. 616 2.3.4. Host 618 For the purposes of this specification, a host is a computer system 619 attached to the Internet (or, in some cases, to a private TCP/IP 620 network) and supporting the SMTP protocol. Hosts are known by names 621 (see the next section); they SHOULD NOT be identified by numerical 622 addresses, i.e., by address literals as described in Section 4.1.2. 624 2.3.5. Domain Names 626 A domain name (or often just a "domain") consists of one or more 627 components, separated by dots if more than one appears. In the case 628 of a top-level domain used by itself in an email address, a single 629 string is used without any dots. This makes the requirement, 630 described in more detail below, that only fully-qualified domain 631 names appear in SMTP transactions on the public Internet, 632 particularly important where top-level domains are involved. These 633 components ("labels" in DNS terminology, RFC 1035 [7]) are restricted 634 for SMTP purposes to consist of a sequence of letters, digits, and 635 hyphens drawn from the ASCII character set [2] and conforming to what 636 RFC 1035 Section 2.3.1 calls the "preferred name syntax". Domain 637 names are used as names of hosts and of other entities in the domain 638 name hierarchy. For example, a domain may refer to an alias (label 639 of a CNAME RR) or the label of Mail eXchanger records to be used to 640 deliver mail instead of representing a host name. See RFC 1035 [7] 641 and Section 5 of this specification. 643 The domain name, as described in this document and in RFC 1035 [7], 644 is the entire, fully-qualified name (often referred to as an "FQDN"). 645 A domain name that is not in FQDN form is no more than a local alias. 646 Local aliases MUST NOT appear in any SMTP transaction. 648 Only resolvable, fully-qualified domain names (FQDNs) are permitted 649 when domain names are used in SMTP. 650 [[CREF3: [[5321bis Editor's Note: does "in the public DNS" or 651 equivalent need to be added to "resolvable"???]]]] 652 In other words, names that can be resolved to MX RRs or address 653 (i.e., A or AAAA) RRs (as discussed in Section 5) are permitted, as 654 are CNAME RRs whose targets can be resolved, in turn, to MX or 655 address RRs. 656 [[CREF4: [[5321bis Editor's Note: it is not clear whether "In other 657 words" really meant "for example" or it is was intended that the only 658 labels permitted are those that own records in one of the above RR 659 types]]]] 660 [[CREF5: [[5321bis Editor's Note: More generally, does this section 661 need work to clarify the relationship to private domain names 662 (discussed on SMTP list starting 2013-03-26)]]]] 663 Local nicknames or unqualified names MUST NOT be used. There are two 664 exceptions to the rule requiring FQDNs: 666 o The domain name given in the EHLO command MUST be either a primary 667 host name (a domain name that resolves to an address RR) or, if 668 the host has no name, an address literal, as described in 669 Section 4.1.3 and discussed further in the EHLO discussion of 670 Section 4.1.4. 672 o The reserved mailbox name "postmaster" may be used in a RCPT 673 command without domain qualification (see Section 4.1.1.3) and 674 MUST be accepted if so used. 676 2.3.6. Buffer and State Table 678 SMTP sessions are stateful, with both parties carefully maintaining a 679 common view of the current state. In this document, we model this 680 state by a virtual "buffer" and a "state table" on the server that 681 may be used by the client to, for example, "clear the buffer" or 682 "reset the state table", causing the information in the buffer to be 683 discarded and the state to be returned to some previous state. 685 2.3.7. Commands and Replies 687 SMTP commands and, unless altered by a service extension, message 688 data, are transmitted from the sender to the receiver via the 689 transmission channel in "lines". 691 An SMTP reply is an acknowledgment (positive or negative) sent in 692 "lines" from receiver to sender via the transmission channel in 693 response to a command. The general form of a reply is a numeric 694 completion code (indicating failure or success) usually followed by a 695 text string. The codes are for use by programs and the text is 696 usually intended for human users. RFC 3463 [38], specifies further 697 structuring of the reply strings, including the use of supplemental 698 and more specific completion codes (see also RFC 5248 [46]). 700 2.3.8. Lines 702 Lines consist of zero or more data characters terminated by the 703 sequence ASCII character "CR" (hex value 0D) followed immediately by 704 ASCII character "LF" (hex value 0A). This termination sequence is 705 denoted as in this document. Conforming implementations MUST 706 NOT recognize or generate any other character or character sequence 707 as a line terminator. Limits MAY be imposed on line lengths by 708 servers (see Section 4). 710 In addition, the appearance of "bare" "CR" or "LF" characters in text 711 (i.e., either without the other) has a long history of causing 712 problems in mail implementations and applications that use the mail 713 system as a tool. SMTP client implementations MUST NOT transmit 714 these characters except when they are intended as line terminators 715 and then MUST, as indicated above, transmit them only as a 716 sequence. 718 2.3.9. Message Content and Mail Data 720 The terms "message content" and "mail data" are used interchangeably 721 in this document to describe the material transmitted after the DATA 722 command is accepted and before the end of data indication is 723 transmitted. Message content includes the message header section and 724 the possibly structured message body. The MIME specification (RFC 725 2045 [29]) provides the standard mechanisms for structured message 726 bodies. 728 2.3.10. Originator, Delivery, Relay, and Gateway Systems 730 This specification makes a distinction among four types of SMTP 731 systems, based on the role those systems play in transmitting 732 electronic mail. An "originating" system (sometimes called an SMTP 733 originator) introduces mail into the Internet or, more generally, 734 into a transport service environment. A "delivery" SMTP system is 735 one that receives mail from a transport service environment and 736 passes it to a mail user agent or deposits it in a message store that 737 a mail user agent is expected to subsequently access. A "relay" SMTP 738 system (usually referred to just as a "relay") receives mail from an 739 SMTP client and transmits it, without modification to the message 740 data other than adding trace information, to another SMTP server for 741 further relaying or for delivery. 743 A "gateway" SMTP system (usually referred to just as a "gateway") 744 receives mail from a client system in one transport environment and 745 transmits it to a server system in another transport environment. 746 Differences in protocols or message semantics between the transport 747 environments on either side of a gateway may require that the gateway 748 system perform transformations to the message that are not permitted 749 to SMTP relay systems. For the purposes of this specification, 750 firewalls that rewrite addresses should be considered as gateways, 751 even if SMTP is used on both sides of them (see RFC 2979 [36]). 752 [[CREF6: [5321bis] [[Note in draft/Placeholder: There has been a 753 request to expand this section, possibly into a more extensive model 754 of Internet mail. Comments from others solicited. In particular, 755 does RFC 5598 make that suggestion OBE?]] ]] 757 2.3.11. Mailbox and Address 759 As used in this specification, an "address" is a character string 760 that identifies a user to whom mail will be sent or a location into 761 which mail will be deposited. The term "mailbox" refers to that 762 depository. The two terms are typically used interchangeably unless 763 the distinction between the location in which mail is placed (the 764 mailbox) and a reference to it (the address) is important. An 765 address normally consists of user and domain specifications. The 766 standard mailbox naming convention is defined to be "local- 767 part@domain"; contemporary usage permits a much broader set of 768 applications than simple "user names". Consequently, and due to a 769 long history of problems when intermediate hosts have attempted to 770 optimize transport by modifying them, the local-part MUST be 771 interpreted and assigned semantics only by the host specified in the 772 domain part of the address. 774 2.4. General Syntax Principles and Transaction Model 776 SMTP commands and replies have a rigid syntax. All commands begin 777 with a command verb. All replies begin with a three digit numeric 778 code. In some commands and replies, arguments are required following 779 the verb or reply code. Some commands do not accept arguments (after 780 the verb), and some reply codes are followed, sometimes optionally, 781 by free form text. In both cases, where text appears, it is 782 separated from the verb or reply code by a space character. Complete 783 definitions of commands and replies appear in Section 4. 785 Verbs and argument values (e.g., "TO:" or "to:" in the RCPT command 786 and extension name keywords) are not case sensitive, with the sole 787 exception in this specification of a mailbox local-part (SMTP 788 Extensions may explicitly specify case-sensitive elements). That is, 789 a command verb, an argument value other than a mailbox local-part, 790 and free form text MAY be encoded in upper case, lower case, or any 791 mixture of upper and lower case with no impact on its meaning. The 792 local-part of a mailbox MUST BE treated as case sensitive. 793 Therefore, SMTP implementations MUST take care to preserve the case 794 of mailbox local-parts. In particular, for some hosts, the user 795 "smith" is different from the user "Smith". However, exploiting the 796 case sensitivity of mailbox local-parts impedes interoperability and 797 is discouraged. Mailbox domains follow normal DNS rules and are 798 hence not case sensitive. 800 A few SMTP servers, in violation of this specification (and RFC 821) 801 require that command verbs be encoded by clients in upper case. 802 Implementations MAY wish to employ this encoding to accommodate those 803 servers. 805 The argument clause consists of a variable-length character string 806 ending with the end of the line, i.e., with the character sequence 807 . The receiver will take no action until this sequence is 808 received. 810 The syntax for each command is shown with the discussion of that 811 command. Common elements and parameters are shown in Section 4.1.2. 813 Commands and replies are composed of characters from the ASCII 814 character set [2]. When the transport service provides an 8-bit byte 815 (octet) transmission channel, each 7-bit character is transmitted, 816 right justified, in an octet with the high-order bit cleared to zero. 817 More specifically, the unextended SMTP service provides 7-bit 818 transport only. An originating SMTP client that has not successfully 819 negotiated an appropriate extension with a particular server (see the 820 next paragraph) MUST NOT transmit messages with information in the 821 high-order bit of octets. If such messages are transmitted in 822 violation of this rule, receiving SMTP servers MAY clear the high- 823 order bit or reject the message as invalid. In general, a relay SMTP 824 SHOULD assume that the message content it has received is valid and, 825 assuming that the envelope permits doing so, relay it without 826 inspecting that content. Of course, if the content is mislabeled and 827 the data path cannot accept the actual content, this may result in 828 the ultimate delivery of a severely garbled message to the recipient. 829 Delivery SMTP systems MAY reject such messages, or return them as 830 undeliverable, rather than deliver them. In the absence of a server- 831 offered extension explicitly permitting it, a sending SMTP system is 832 not permitted to send envelope commands in any character set other 833 than US-ASCII. Receiving systems SHOULD reject such commands, 834 normally using "500 syntax error - invalid character" replies. 836 8-bit message content transmission MAY be requested of the server by 837 a client using extended SMTP facilities, notably the "8BITMIME" 838 extension, RFC 1652 [23]. 8BITMIME SHOULD be supported by SMTP 839 servers. However, it MUST NOT be construed as authorization to 840 transmit unrestricted 8-bit material, nor does 8BITMIME authorize 841 transmission of any envelope material in other than ASCII. 8BITMIME 842 MUST NOT be requested by senders for material with the high bit on 843 that is not in MIME format with an appropriate content-transfer 844 encoding; servers MAY reject such messages. 846 The metalinguistic notation used in this document corresponds to the 847 "Augmented BNF" used in other Internet mail system documents. The 848 reader who is not familiar with that syntax should consult the ABNF 849 specification in RFC 5234 [5]. Metalanguage terms used in running 850 text are surrounded by pointed brackets (e.g., ) for clarity. 851 The reader is cautioned that the grammar expressed in the 852 metalanguage is not comprehensive. There are many instances in which 853 provisions in the text constrain or otherwise modify the syntax or 854 semantics implied by the grammar. 856 3. The SMTP Procedures: An Overview 858 This section contains descriptions of the procedures used in SMTP: 859 session initiation, mail transaction, forwarding mail, verifying 860 mailbox names and expanding mailing lists, and opening and closing 861 exchanges. Comments on relaying, a note on mail domains, and a 862 discussion of changing roles are included at the end of this section. 863 Several complete scenarios are presented in Appendix D. 865 3.1. Session Initiation 867 An SMTP session is initiated when a client opens a connection to a 868 server and the server responds with an opening message. 870 SMTP server implementations MAY include identification of their 871 software and version information in the connection greeting reply 872 after the 220 code, a practice that permits more efficient isolation 873 and repair of any problems. Implementations MAY make provision for 874 SMTP servers to disable the software and version announcement where 875 it causes security concerns. While some systems also identify their 876 contact point for mail problems, this is not a substitute for 877 maintaining the required "postmaster" address (see Section 4). 879 The SMTP protocol allows a server to formally reject a mail session 880 while still allowing the initial connection as follows: a 554 881 response MAY be given in the initial connection opening message 882 instead of the 220. A server taking this approach MUST still wait 883 for the client to send a QUIT (see Section 4.1.1.10) before closing 884 the connection and SHOULD respond to any intervening commands with 885 "503 bad sequence of commands". Since an attempt to make an SMTP 886 connection to such a system is probably in error, a server returning 887 a 554 response on connection opening SHOULD provide enough 888 information in the reply text to facilitate debugging of the sending 889 system. 891 3.2. Client Initiation 893 Once the server has sent the greeting (welcoming) message and the 894 client has received it, the client normally sends the EHLO command to 895 the server, indicating the client's identity. In addition to opening 896 the session, use of EHLO indicates that the client is able to process 897 service extensions and requests that the server provide a list of the 898 extensions it supports. Older SMTP systems that are unable to 899 support service extensions, and contemporary clients that do not 900 require service extensions in the mail session being initiated, MAY 901 use HELO instead of EHLO. Servers MUST NOT return the extended EHLO- 902 style response to a HELO command. For a particular connection 903 attempt, if the server returns a "command not recognized" response to 904 EHLO, the client SHOULD be able to fall back and send HELO. 906 In the EHLO command, the host sending the command identifies itself; 907 the command may be interpreted as saying "Hello, I am " (and, 908 in the case of EHLO, "and I support service extension requests"). 910 3.3. Mail Transactions 912 There are three steps to SMTP mail transactions. The transaction 913 starts with a MAIL command that gives the sender identification. (In 914 general, the MAIL command may be sent only when no mail transaction 915 is in progress; see Section 4.1.4.) A series of one or more RCPT 916 commands follows, giving the receiver information. Then, a DATA 917 command initiates transfer of the mail data and is terminated by the 918 "end of mail" data indicator, which also confirms the transaction. 920 The first step in the procedure is the MAIL command. 922 MAIL FROM: [SP ] 924 This command tells the SMTP-receiver that a new mail transaction is 925 starting and to reset all its state tables and buffers, including any 926 recipients or mail data. The portion of the first or 927 only argument contains the source mailbox (between "<" and ">" 928 brackets), which can be used to report errors (see Section 4.2 for a 929 discussion of error reporting). If accepted, the SMTP server returns 930 a "250 OK" reply. If the mailbox specification is not acceptable for 931 some reason, the server MUST return a reply indicating whether the 932 failure is permanent (i.e., will occur again if the client tries to 933 send the same address again) or temporary (i.e., the address might be 934 accepted if the client tries again later). Despite the apparent 935 scope of this requirement, there are circumstances in which the 936 acceptability of the reverse-path may not be determined until one or 937 more forward-paths (in RCPT commands) can be examined. In those 938 cases, the server MAY reasonably accept the reverse-path (with a 250 939 reply) and then report problems after the forward-paths are received 940 and examined. Normally, failures produce 550 or 553 replies. 942 Historically, the was permitted to contain more than 943 just a mailbox; however, contemporary systems SHOULD NOT use source 944 routing (see Appendix C). 946 The optional are associated with negotiated SMTP 947 service extensions (see Section 2.2). 949 The second step in the procedure is the RCPT command. This step of 950 the procedure can be repeated any number of times. 952 RCPT TO: [ SP ] 954 The first or only argument to this command includes a forward-path 955 (normally a mailbox and domain, always surrounded by "<" and ">" 956 brackets) identifying one recipient. If accepted, the SMTP server 957 returns a "250 OK" reply and stores the forward-path. If the 958 recipient is known not to be a deliverable address, the SMTP server 959 returns a 550 reply, typically with a string such as "no such user - 960 " and the mailbox name (other circumstances and reply codes are 961 possible). 963 The can contain more than just a mailbox. 964 Historically, the was permitted to contain a source 965 routing list of hosts and the destination mailbox; however, 966 contemporary SMTP clients SHOULD NOT utilize source routes (see 967 Appendix C). Servers MUST be prepared to encounter a list of source 968 routes in the forward-path, but they SHOULD ignore the routes or MAY 969 decline to support the relaying they imply. Similarly, servers MAY 970 decline to accept mail that is destined for other hosts or systems. 971 These restrictions make a server useless as a relay for clients that 972 do not support full SMTP functionality. Consequently, restricted- 973 capability clients MUST NOT assume that any SMTP server on the 974 Internet can be used as their mail processing (relaying) site. If a 975 RCPT command appears without a previous MAIL command, the server MUST 976 return a 503 "Bad sequence of commands" response. The optional 977 are associated with negotiated SMTP service 978 extensions (see Section 2.2). [[CREF7: [5321bis] JcK Note for 979 2821ter (5321bis): this section would be improved by being more 980 specific about where mail transactions begin and end and then talking 981 about "transaction state" here, rather than specific prior commands. 982 --JcK]] 984 Since it has been a common source of errors, it is worth noting that 985 spaces are not permitted on either side of the colon following FROM 986 in the MAIL command or TO in the RCPT command. The syntax is exactly 987 as given above. 989 The third step in the procedure is the DATA command (or some 990 alternative specified in a service extension). 992 DATA 994 If accepted, the SMTP server returns a 354 Intermediate reply and 995 considers all succeeding lines up to but not including the end of 996 mail data indicator to be the message text. When the end of text is 997 successfully received and stored, the SMTP-receiver sends a "250 OK" 998 reply. 1000 Since the mail data is sent on the transmission channel, the end of 1001 mail data must be indicated so that the command and reply dialog can 1002 be resumed. SMTP indicates the end of the mail data by sending a 1003 line containing only a "." (period or full stop). A transparency 1004 procedure is used to prevent this from interfering with the user's 1005 text (see Section 4.5.2). 1007 The end of mail data indicator also confirms the mail transaction and 1008 tells the SMTP server to now process the stored recipients and mail 1009 data. If accepted, the SMTP server returns a "250 OK" reply. The 1010 DATA command can fail at only two points in the protocol exchange: 1012 If there was no MAIL, or no RCPT, command, or all such commands were 1013 rejected, the server MAY return a "command out of sequence" (503) or 1014 "no valid recipients" (554) reply in response to the DATA command. 1015 If one of those replies (or any other 5yz reply) is received, the 1016 client MUST NOT send the message data; more generally, message data 1017 MUST NOT be sent unless a 354 reply is received. 1019 If the verb is initially accepted and the 354 reply issued, the DATA 1020 command should fail only if the mail transaction was incomplete (for 1021 example, no recipients), if resources were unavailable (including, of 1022 course, the server unexpectedly becoming unavailable), or if the 1023 server determines that the message should be rejected for policy or 1024 other reasons. 1026 However, in practice, some servers do not perform recipient 1027 verification until after the message text is received. These servers 1028 SHOULD treat a failure for one or more recipients as a "subsequent 1029 failure" and return a mail message as discussed in Section 6 and, in 1030 particular, in Section 6.1. Using a "550 mailbox not found" (or 1031 equivalent) reply code after the data are accepted makes it difficult 1032 or impossible for the client to determine which recipients failed. 1034 When the RFC 822 format ([16], [11]) is being used, the mail data 1035 include the header fields such as those named Date, Subject, To, Cc, 1036 and From. Server SMTP systems SHOULD NOT reject messages based on 1037 perceived defects in the RFC 822 or MIME (RFC 2045 [29]) message 1038 header section or message body. In particular, they MUST NOT reject 1039 messages in which the numbers of Resent-header fields do not match or 1040 Resent-to appears without Resent-from and/or Resent-date. 1042 Mail transaction commands MUST be used in the order discussed above. 1044 3.4. Forwarding for Address Correction or Updating 1046 Forwarding support is most often required to consolidate and simplify 1047 addresses within, or relative to, some enterprise and less frequently 1048 to establish addresses to link a person's prior address with a 1049 current one. Silent forwarding of messages (without server 1050 notification to the sender), for security or non-disclosure purposes, 1051 is common in the contemporary Internet. 1053 In both the enterprise and the "new address" cases, information 1054 hiding (and sometimes security) considerations argue against exposure 1055 of the "final" address through the SMTP protocol as a side effect of 1056 the forwarding activity. This may be especially important when the 1057 final address may not even be reachable by the sender. Consequently, 1058 the "forwarding" mechanisms described in Section 3.2 of RFC 821, and 1059 especially the 251 (corrected destination) and 551 reply codes from 1060 RCPT must be evaluated carefully by implementers and, when they are 1061 available, by those configuring systems (see also Section 7.4). 1063 In particular: 1065 o Servers MAY forward messages when they are aware of an address 1066 change. When they do so, they MAY either provide address-updating 1067 information with a 251 code, or may forward "silently" and return 1068 a 250 code. However, if a 251 code is used, they MUST NOT assume 1069 that the client will actually update address information or even 1070 return that information to the user. 1072 Alternately, 1074 o Servers MAY reject messages or return them as non-deliverable when 1075 they cannot be delivered precisely as addressed. When they do so, 1076 they MAY either provide address-updating information with a 551 1077 code, or may reject the message as undeliverable with a 550 code 1078 and no address-specific information. However, if a 551 code is 1079 used, they MUST NOT assume that the client will actually update 1080 address information or even return that information to the user. 1082 SMTP server implementations that support the 251 and/or 551 reply 1083 codes SHOULD provide configuration mechanisms so that sites that 1084 conclude that they would undesirably disclose information can disable 1085 or restrict their use. 1087 3.5. Commands for Debugging Addresses 1089 3.5.1. Overview 1091 SMTP provides commands to verify a user name or obtain the content of 1092 a mailing list. This is done with the VRFY and EXPN commands, which 1093 have character string arguments. Implementations SHOULD support VRFY 1094 and EXPN (however, see Section 3.5.2 and Section 7.3). 1096 For the VRFY command, the string is a user name or a user name and 1097 domain (see below). If a normal (i.e., 250) response is returned, 1098 the response MAY include the full name of the user and MUST include 1099 the mailbox of the user. It MUST be in either of the following 1100 forms: 1102 User Name 1103 local-part@domain 1105 When a name that is the argument to VRFY could identify more than one 1106 mailbox, the server MAY either note the ambiguity or identify the 1107 alternatives. In other words, any of the following are legitimate 1108 responses to VRFY: 1110 553 User ambiguous 1112 or 1114 553- Ambiguous; Possibilities are 1115 553-Joe Smith 1116 553-Harry Smith 1117 553 Melvin Smith 1119 or 1121 553-Ambiguous; Possibilities 1122 553- 1123 553- 1124 553 1126 Under normal circumstances, a client receiving a 553 reply would be 1127 expected to expose the result to the user. Use of exactly the forms 1128 given, and the "user ambiguous" or "ambiguous" keywords, possibly 1129 supplemented by extended reply codes, such as those described in RFC 1130 3463 [38], will facilitate automated translation into other languages 1131 as needed. Of course, a client that was highly automated or that was 1132 operating in another language than English might choose to try to 1133 translate the response to return some other indication to the user 1134 than the literal text of the reply, or to take some automated action 1135 such as consulting a directory service for additional information 1136 before reporting to the user. 1138 For the EXPN command, the string identifies a mailing list, and the 1139 successful (i.e., 250) multiline response MAY include the full name 1140 of the users and MUST give the mailboxes on the mailing list. 1142 In some hosts, the distinction between a mailing list and an alias 1143 for a single mailbox is a bit fuzzy, since a common data structure 1144 may hold both types of entries, and it is possible to have mailing 1145 lists containing only one mailbox. If a request is made to apply 1146 VRFY to a mailing list, a positive response MAY be given if a message 1147 so addressed would be delivered to everyone on the list, otherwise an 1148 error SHOULD be reported (e.g., "550 That is a mailing list, not a 1149 user" or "252 Unable to verify members of mailing list"). If a 1150 request is made to expand a user name, the server MAY return a 1151 positive response consisting of a list containing one name, or an 1152 error MAY be reported (e.g., "550 That is a user name, not a mailing 1153 list"). 1155 In the case of a successful multiline reply (normal for EXPN), 1156 exactly one mailbox is to be specified on each line of the reply. 1157 The case of an ambiguous request is discussed above. 1159 "User name" is a fuzzy term and has been used deliberately. An 1160 implementation of the VRFY or EXPN commands MUST include at least 1161 recognition of local mailboxes as "user names". However, since 1162 current Internet practice often results in a single host handling 1163 mail for multiple domains, hosts, especially hosts that provide this 1164 functionality, SHOULD accept the "local-part@domain" form as a "user 1165 name"; hosts MAY also choose to recognize other strings as "user 1166 names". 1168 The case of expanding a mailbox list requires a multiline reply, such 1169 as: 1171 C: EXPN Example-People 1172 S: 250-Jon Postel 1173 S: 250-Fred Fonebone 1174 S: 250 Sam Q. Smith 1176 or 1178 C: EXPN Executive-Washroom-List 1179 S: 550 Access Denied to You. 1181 The character string arguments of the VRFY and EXPN commands cannot 1182 be further restricted due to the variety of implementations of the 1183 user name and mailbox list concepts. On some systems, it may be 1184 appropriate for the argument of the EXPN command to be a file name 1185 for a file containing a mailing list, but again there are a variety 1186 of file naming conventions in the Internet. Similarly, historical 1187 variations in what is returned by these commands are such that the 1188 response SHOULD be interpreted very carefully, if at all, and SHOULD 1189 generally only be used for diagnostic purposes. 1191 3.5.2. VRFY Normal Response 1193 When normal (2yz or 551) responses are returned from a VRFY or EXPN 1194 request, the reply MUST include the name using a "" construction, where "domain" is a fully-qualified 1196 domain name. In circumstances exceptional enough to justify 1197 violating the intent of this specification, free-form text MAY be 1198 returned. In order to facilitate parsing by both computers and 1199 people, addresses SHOULD appear in pointed brackets. When addresses, 1200 rather than free-form debugging information, are returned, EXPN and 1201 VRFY MUST return only valid domain addresses that are usable in SMTP 1202 RCPT commands. Consequently, if an address implies delivery to a 1203 program or other system, the mailbox name used to reach that target 1204 MUST be given. Paths (explicit source routes) MUST NOT be returned 1205 by VRFY or EXPN. 1207 Server implementations SHOULD support both VRFY and EXPN. For 1208 security reasons, implementations MAY provide local installations a 1209 way to disable either or both of these commands through configuration 1210 options or the equivalent (see Section 7.3). When these commands are 1211 supported, they are not required to work across relays when relaying 1212 is supported. Since they were both optional in RFC 821, but VRFY was 1213 made mandatory in RFC 1123 [3], if EXPN is supported, it MUST be 1214 listed as a service extension in an EHLO response. VRFY MAY be 1215 listed as a convenience but, since support for it is required, SMTP 1216 clients are not required to check for its presence on the extension 1217 list before using it. 1219 3.5.3. Meaning of VRFY or EXPN Success Response 1221 A server MUST NOT return a 250 code in response to a VRFY or EXPN 1222 command unless it has actually verified the address. In particular, 1223 a server MUST NOT return 250 if all it has done is to verify that the 1224 syntax given is valid. In that case, 502 (Command not implemented) 1225 or 500 (Syntax error, command unrecognized) SHOULD be returned. As 1226 stated elsewhere, implementation (in the sense of actually validating 1227 addresses and returning information) of VRFY and EXPN are strongly 1228 recommended. Hence, implementations that return 500 or 502 for VRFY 1229 are not in full compliance with this specification. 1231 There may be circumstances where an address appears to be valid but 1232 cannot reasonably be verified in real time, particularly when a 1233 server is acting as a mail exchanger for another server or domain. 1234 "Apparent validity", in this case, would normally involve at least 1235 syntax checking and might involve verification that any domains 1236 specified were ones to which the host expected to be able to relay 1237 mail. In these situations, reply code 252 SHOULD be returned. These 1238 cases parallel the discussion of RCPT verification in Section 2.1. 1239 Similarly, the discussion in Section 3.4 applies to the use of reply 1240 codes 251 and 551 with VRFY (and EXPN) to indicate addresses that are 1241 recognized but that would be forwarded or rejected were mail received 1242 for them. Implementations generally SHOULD be more aggressive about 1243 address verification in the case of VRFY than in the case of RCPT, 1244 even if it takes a little longer to do so. 1246 3.5.4. Semantics and Applications of EXPN 1248 EXPN is often very useful in debugging and understanding problems 1249 with mailing lists and multiple-target-address aliases. Some systems 1250 have attempted to use source expansion of mailing lists as a means of 1251 eliminating duplicates. The propagation of aliasing systems with 1252 mail on the Internet for hosts (typically with MX and CNAME DNS 1253 records), for mailboxes (various types of local host aliases), and in 1254 various proxying arrangements has made it nearly impossible for these 1255 strategies to work consistently, and mail systems SHOULD NOT attempt 1256 them. 1258 3.6. Relaying and Mail Routing 1260 3.6.1. Source Routes and Relaying 1262 In general, the availability of Mail eXchanger records in the domain 1263 name system (RFC 1035 [7], RFC 974 [19]) makes the use of explicit 1264 source routes in the Internet mail system unnecessary. Many 1265 historical problems with the interpretation of explicit source routes 1266 have made their use undesirable. SMTP clients SHOULD NOT generate 1267 explicit source routes except under unusual circumstances. SMTP 1268 servers MAY decline to act as mail relays or to accept addresses that 1269 specify source routes. When route information is encountered, SMTP 1270 servers MAY ignore the route information and simply send to the final 1271 destination specified as the last element in the route and SHOULD do 1272 so. There has been an invalid practice of using names that do not 1273 appear in the DNS as destination names, with the senders counting on 1274 the intermediate hosts specified in source routing to resolve any 1275 problems. If source routes are stripped, this practice will cause 1276 failures. This is one of several reasons why SMTP clients MUST NOT 1277 generate invalid source routes or depend on serial resolution of 1278 names in such routes. [[CREF8: [5321bis] Jck 20091023: "of names..." 1279 added for clarity"]] 1281 When source routes are not used, the process described in RFC 821 for 1282 constructing a reverse-path from the forward-path is not applicable 1283 and the reverse-path at the time of delivery will simply be the 1284 address that appeared in the MAIL command. 1286 3.6.2. Mail eXchange Records and Relaying 1288 A relay SMTP server is usually the target of a DNS MX record that 1289 designates it, rather than the final delivery system. The relay 1290 server may accept or reject the task of relaying the mail in the same 1291 way it accepts or rejects mail for a local user. If it accepts the 1292 task, it then becomes an SMTP client, establishes a transmission 1293 channel to the next SMTP server specified in the DNS (according to 1294 the rules in Section 5), and sends it the mail. If it declines to 1295 relay mail to a particular address for policy reasons, a 550 response 1296 SHOULD be returned. 1298 This specification does not deal with the verification of return 1299 paths for use in delivery notifications. Recent work, such as that 1300 on SPF [42] and DKIM [44] [45], has been done to provide ways to 1301 ascertain that an address is valid or belongs to the person who 1302 actually sent the message. 1303 [[5321bis Editor's Note: Proposed erratum (4055) suggests that DKIM 1304 and SPF have nothing to do with this and that everything after the 1305 first sentence should be dropped. An alternative would be to tune 1306 the texts. ???]] 1307 A server MAY attempt to verify the return path before using its 1308 address for delivery notifications, but methods of doing so are not 1309 defined here nor is any particular method recommended at this time. 1311 3.6.3. Message Submission Servers as Relays 1313 Many mail-sending clients exist, especially in conjunction with 1314 facilities that receive mail via POP3 or IMAP, that have limited 1315 capability to support some of the requirements of this specification, 1316 such as the ability to queue messages for subsequent delivery 1317 attempts. For these clients, it is common practice to make private 1318 arrangements to send all messages to a single server for processing 1319 and subsequent distribution. SMTP, as specified here, is not ideally 1320 suited for this role. A standardized mail submission protocol has 1321 been developed that is gradually superseding practices based on SMTP 1322 (see RFC 4409 [43]). In any event, because these arrangements are 1323 private and fall outside the scope of this specification, they are 1324 not described here. 1326 It is important to note that MX records can point to SMTP servers 1327 that act as gateways into other environments, not just SMTP relays 1328 and final delivery systems; see Sections 3.7 and 5. 1330 If an SMTP server has accepted the task of relaying the mail and 1331 later finds that the destination is incorrect or that the mail cannot 1332 be delivered for some other reason, then it MUST construct an 1333 "undeliverable mail" notification message and send it to the 1334 originator of the undeliverable mail (as indicated by the reverse- 1335 path). Formats specified for non-delivery reports by other standards 1336 (see, for example, RFC 3461 [12] and RFC 3464 [13]) SHOULD be used if 1337 possible. 1339 This notification message must be from the SMTP server at the relay 1340 host or the host that first determines that delivery cannot be 1341 accomplished. Of course, SMTP servers MUST NOT send notification 1342 messages about problems transporting notification messages. One way 1343 to prevent loops in error reporting is to specify a null reverse-path 1344 in the MAIL command of a notification message. When such a message 1345 is transmitted, the reverse-path MUST be set to null (see 1346 Section 4.5.5 for additional discussion). A MAIL command with a null 1347 reverse-path appears as follows: 1349 MAIL FROM:<> 1351 As discussed in Section 6.4, a relay SMTP has no need to inspect or 1352 act upon the header section or body of the message data and MUST NOT 1353 do so except to add its own "Received:" header field (Section 4.4) 1354 and, optionally, to attempt to detect looping in the mail system (see 1355 Section 6.3). Of course, this prohibition also applies to any 1356 modifications of these header fields or text (see also Section 7.9). 1358 3.7. Mail Gatewaying 1360 While the relay function discussed above operates within the Internet 1361 SMTP transport service environment, MX records or various forms of 1362 explicit routing may require that an intermediate SMTP server perform 1363 a translation function between one transport service and another. As 1364 discussed in Section 2.3.10, when such a system is at the boundary 1365 between two transport service environments, we refer to it as a 1366 "gateway" or "gateway SMTP". 1368 Gatewaying mail between different mail environments, such as 1369 different mail formats and protocols, is complex and does not easily 1370 yield to standardization. However, some general requirements may be 1371 given for a gateway between the Internet and another mail 1372 environment. 1374 3.7.1. Header Fields in Gatewaying 1376 Header fields MAY be rewritten when necessary as messages are 1377 gatewayed across mail environment boundaries. This may involve 1378 inspecting the message body or interpreting the local-part of the 1379 destination address in spite of the prohibitions in Section 6.4. 1381 Other mail systems gatewayed to the Internet often use a subset of 1382 the RFC 822 header section or provide similar functionality with a 1383 different syntax, but some of these mail systems do not have an 1384 equivalent to the SMTP envelope. Therefore, when a message leaves 1385 the Internet environment, it may be necessary to fold the SMTP 1386 envelope information into the message header section. A possible 1387 solution would be to create new header fields to carry the envelope 1388 information (e.g., "X-SMTP-MAIL:" and "X-SMTP-RCPT:"); however, this 1389 would require changes in mail programs in foreign environments and 1390 might risk disclosure of private information (see Section 7.2). 1392 3.7.2. Received Lines in Gatewaying 1394 When forwarding a message into or out of the Internet environment, a 1395 gateway MUST prepend a Received: line, but it MUST NOT alter in any 1396 way a Received: line that is already in the header section. 1398 "Received:" header fields of messages originating from other 1399 environments may not conform exactly to this specification. However, 1400 the most important use of Received: lines is for debugging mail 1401 faults, and this debugging can be severely hampered by well-meaning 1402 gateways that try to "fix" a Received: line. As another consequence 1403 of trace header fields arising in non-SMTP environments, receiving 1404 systems MUST NOT reject mail based on the format of a trace header 1405 field and SHOULD be extremely robust in the light of unexpected 1406 information or formats in those header fields. 1408 The gateway SHOULD indicate the environment and protocol in the "via" 1409 clauses of Received header field(s) that it supplies. 1411 3.7.3. Addresses in Gatewaying 1413 From the Internet side, the gateway SHOULD accept all valid address 1414 formats in SMTP commands and in the RFC 822 header section, and all 1415 valid RFC 822 messages. Addresses and header fields generated by 1416 gateways MUST conform to applicable standards (including this one and 1417 RFC 5322 [11]). Gateways are, of course, subject to the same rules 1418 for handling source routes as those described for other SMTP systems 1419 in Section 3.3. 1421 3.7.4. Other Header Fields in Gatewaying 1423 The gateway MUST ensure that all header fields of a message that it 1424 forwards into the Internet mail environment meet the requirements for 1425 Internet mail. In particular, all addresses in "From:", "To:", 1426 "Cc:", etc., header fields MUST be transformed (if necessary) to 1427 satisfy the standard header syntax of RFC 5322 [11], MUST reference 1428 only fully-qualified domain names, and MUST be effective and useful 1429 for sending replies. The translation algorithm used to convert mail 1430 from the Internet protocols to another environment's protocol SHOULD 1431 ensure that error messages from the foreign mail environment are 1432 delivered to the reverse-path from the SMTP envelope, not to an 1433 address in the "From:", "Sender:", or similar header fields of the 1434 message. 1436 3.7.5. Envelopes in Gatewaying 1438 Similarly, when forwarding a message from another environment into 1439 the Internet, the gateway SHOULD set the envelope return path in 1440 accordance with an error message return address, if supplied by the 1441 foreign environment. If the foreign environment has no equivalent 1442 concept, the gateway must select and use a best approximation, with 1443 the message originator's address as the default of last resort. 1445 3.8. Terminating Sessions and Connections 1447 An SMTP connection is terminated when the client sends a QUIT 1448 command. The server responds with a positive reply code, after which 1449 it closes the connection. 1451 An SMTP server MUST NOT intentionally close the connection under 1452 normal operational circumstances (see Section 7.8) except: 1454 o After receiving a QUIT command and responding with a 221 reply. 1456 o After detecting the need to shut down the SMTP service and 1457 returning a 421 reply code. This reply code can be issued after 1458 the server receives any command or, if necessary, asynchronously 1459 from command receipt (on the assumption that the client will 1460 receive it after the next command is issued). 1462 o After a timeout, as specified in Section 4.5.3.2, occurs waiting 1463 for the client to send a command or data. 1465 In particular, a server that closes connections in response to 1466 commands that are not understood is in violation of this 1467 specification. Servers are expected to be tolerant of unknown 1468 commands, issuing a 500 reply and awaiting further instructions from 1469 the client. 1471 An SMTP server that is forcibly shut down via external means SHOULD 1472 attempt to send a line containing a 421 reply code to the SMTP client 1473 before exiting. The SMTP client will normally read the 421 reply 1474 code after sending its next command. 1476 SMTP clients that experience a connection close, reset, or other 1477 communications failure due to circumstances not under their control 1478 (in violation of the intent of this specification but sometimes 1479 unavoidable) SHOULD, to maintain the robustness of the mail system, 1480 treat the mail transaction as if a 421 response had been received and 1481 act accordingly. 1483 3.9. Mailing Lists and Aliases 1485 [[CREF9: [5321bis] If "alias and list models" are explained 1486 elsewhere, cross reference". Also note that this section appears to 1487 prohibit an exploder from adding List-* headers. That needs to be 1488 finessed.]] 1489 An SMTP-capable host SHOULD support both the alias and the list 1490 models of address expansion for multiple delivery. When a message is 1491 delivered or forwarded to each address of an expanded list form, the 1492 return address in the envelope ("MAIL FROM:") MUST be changed to be 1493 the address of a person or other entity who administers the list. 1494 However, in this case, the message header section (RFC 5322 [11]) 1495 MUST be left unchanged; in particular, the "From" field of the header 1496 section is unaffected. 1498 An important mail facility is a mechanism for multi-destination 1499 delivery of a single message, by transforming (or "expanding" or 1500 "exploding") a pseudo-mailbox address into a list of destination 1501 mailbox addresses. When a message is sent to such a pseudo-mailbox 1502 (sometimes called an "exploder"), copies are forwarded or 1503 redistributed to each mailbox in the expanded list. Servers SHOULD 1504 simply utilize the addresses on the list; application of heuristics 1505 or other matching rules to eliminate some addresses, such as that of 1506 the originator, is strongly discouraged. We classify such a pseudo- 1507 mailbox as an "alias" or a "list", depending upon the expansion 1508 rules. 1510 3.9.1. Alias 1512 To expand an alias, the recipient mailer simply replaces the pseudo- 1513 mailbox address in the envelope with each of the expanded addresses 1514 in turn; the rest of the envelope and the message body are left 1515 unchanged. The message is then delivered or forwarded to each 1516 expanded address. 1518 3.9.2. List 1520 A mailing list may be said to operate by "redistribution" rather than 1521 by "forwarding". To expand a list, the recipient mailer replaces the 1522 pseudo-mailbox address in the envelope with each of the expanded 1523 addresses in turn. The return (backward-pointing) address in the 1524 envelope is changed so that all error messages generated by the final 1525 deliveries will be returned to a list administrator, not to the 1526 message originator, who generally has no control over the contents of 1527 the list and will typically find error messages annoying. Note that 1528 the key difference between handling aliases (Section 3.9.1) and 1529 forwarding (this subsection) is the change to the backward-pointing 1530 address in this case. When a list constrains its processing to the 1531 very limited set of modifications and actions described here, it is 1532 attempting to emulate an MTA; such lists can be treated as a 1533 continuation in email transit. 1535 There exist mailing lists that perform additional, sometimes 1536 extensive, modifications to a message and its envelope. Such mailing 1537 lists need to be viewed as full MUAs, which accept a delivery and 1538 post a new message. 1540 4. The SMTP Specifications 1542 4.1. SMTP Commands 1544 4.1.1. Command Semantics and Syntax 1546 The SMTP commands define the mail transfer or the mail system 1547 function requested by the user. SMTP commands are character strings 1548 terminated by . The commands themselves are alphabetic 1549 characters terminated by if parameters follow and 1550 otherwise. (In the interest of improved interoperability, SMTP 1551 receivers SHOULD tolerate trailing white space before the terminating 1552 .) The syntax of the local part of a mailbox MUST conform to 1553 receiver site conventions and the syntax specified in Section 4.1.2. 1554 The SMTP commands are discussed below. The SMTP replies are 1555 discussed in Section 4.2. 1557 A mail transaction involves several data objects that are 1558 communicated as arguments to different commands. The reverse-path is 1559 the argument of the MAIL command, the forward-path is the argument of 1560 the RCPT command, and the mail data is the argument of the DATA 1561 command. These arguments or data objects must be transmitted and 1562 held, pending the confirmation communicated by the end of mail data 1563 indication that finalizes the transaction. The model for this is 1564 that distinct buffers are provided to hold the types of data objects; 1565 that is, there is a reverse-path buffer, a forward-path buffer, and a 1566 mail data buffer. Specific commands cause information to be appended 1567 to a specific buffer, or cause one or more buffers to be cleared. 1569 Several commands (RSET, DATA, QUIT) are specified as not permitting 1570 parameters. In the absence of specific extensions offered by the 1571 server and accepted by the client, clients MUST NOT send such 1572 parameters and servers SHOULD reject commands containing them as 1573 having invalid syntax. 1575 4.1.1.1. Extended HELLO (EHLO) or HELLO (HELO) 1577 These commands are used to identify the SMTP client to the SMTP 1578 server. The argument clause contains the fully-qualified domain name 1579 of the SMTP client, if one is available. In situations in which the 1580 SMTP client system does not have a meaningful domain name (e.g., when 1581 its address is dynamically allocated and no reverse mapping record is 1582 available), the client SHOULD send an address literal (see 1583 Section 4.1.3). 1585 RFC 2821, and some earlier informal practices, encouraged following 1586 the literal by information that would help to identify the client 1587 system. That convention was not widely supported, and many SMTP 1588 servers considered it an error. In the interest of interoperability, 1589 it is probably wise for servers to be prepared for this string to 1590 occur, but SMTP clients SHOULD NOT send it. 1592 The SMTP server identifies itself to the SMTP client in the 1593 connection greeting reply and in the response to this command. 1595 A client SMTP SHOULD start an SMTP session by issuing the EHLO 1596 command. If the SMTP server supports the SMTP service extensions, it 1597 will give a successful response, a failure response, or an error 1598 response. If the SMTP server, in violation of this specification, 1599 does not support any SMTP service extensions, it will generate an 1600 error response. Older client SMTP systems MAY, as discussed above, 1601 use HELO (as specified in RFC 821) instead of EHLO, and servers MUST 1602 support the HELO command and reply properly to it. In any event, a 1603 client MUST issue HELO or EHLO before starting a mail transaction. 1605 These commands, and a "250 OK" reply to one of them, confirm that 1606 both the SMTP client and the SMTP server are in the initial state, 1607 that is, there is no transaction in progress and all state tables and 1608 buffers are cleared. 1610 Syntax: 1612 ehlo = "EHLO" SP ( Domain / address-literal ) CRLF 1614 helo = "HELO" SP Domain CRLF 1616 Normally, the response to EHLO will be a multiline reply. Each line 1617 of the response contains a keyword and, optionally, one or more 1618 parameters. Following the normal syntax for multiline replies, these 1619 keywords follow the code (250) and a hyphen for all but the last 1620 line, and the code and a space for the last line. The syntax for a 1621 positive response, using the ABNF notation and terminal symbols of 1622 RFC 5234 [5], is: 1624 ehlo-ok-rsp = ( "250" SP Domain [ SP ehlo-greet ] CRLF ) 1625 / ( "250-" Domain [ SP ehlo-greet ] CRLF 1626 *( "250-" ehlo-line CRLF ) 1627 "250" SP ehlo-line CRLF ) 1629 ehlo-greet = 1*(%d0-9 / %d11-12 / %d14-127) 1630 ; string of any characters other than CR or LF 1632 ehlo-line = ehlo-keyword *( SP ehlo-param ) 1634 ehlo-keyword = (ALPHA / DIGIT) *(ALPHA / DIGIT / "-") 1635 ; additional syntax of ehlo-params depends on 1636 ; ehlo-keyword 1638 ehlo-param = 1*(%d33-126) 1639 ; any CHAR excluding and all 1640 ; control characters (US-ASCII 0-31 and 127 1641 ; inclusive) 1643 Although EHLO keywords may be specified in upper, lower, or mixed 1644 case, they MUST always be recognized and processed in a case- 1645 insensitive manner. This is simply an extension of practices 1646 specified in RFC 821 and Section 2.4. 1648 The EHLO response MUST contain keywords (and associated parameters if 1649 required) for all commands not listed as "required" in Section 4.5.1 1650 excepting only private-use commands as described in Section 4.1.5. 1651 Private-use commands MAY be listed. 1653 4.1.1.2. MAIL (MAIL) 1655 This command is used to initiate a mail transaction in which the mail 1656 data is delivered to an SMTP server that may, in turn, deliver it to 1657 one or more mailboxes or pass it on to another system (possibly using 1658 SMTP). The argument clause contains a reverse-path and may contain 1659 optional parameters. In general, the MAIL command may be sent only 1660 when no mail transaction is in progress, see Section 4.1.4. 1662 The reverse-path consists of the sender mailbox. Historically, that 1663 mailbox might optionally have been preceded by a list of hosts, but 1664 that behavior is now deprecated (see Appendix C). In some types of 1665 reporting messages for which a reply is likely to cause a mail loop 1666 (for example, mail delivery and non-delivery notifications), the 1667 reverse-path may be null (see Section 3.6). 1669 This command clears the reverse-path buffer, the forward-path buffer, 1670 and the mail data buffer, and it inserts the reverse-path information 1671 from its argument clause into the reverse-path buffer. 1673 If service extensions were negotiated, the MAIL command may also 1674 carry parameters associated with a particular service extension. 1676 Syntax: 1678 mail = "MAIL FROM:" Reverse-path 1679 [SP Mail-parameters] CRLF 1681 4.1.1.3. RECIPIENT (RCPT) 1683 This command is used to identify an individual recipient of the mail 1684 data; multiple recipients are specified by multiple uses of this 1685 command. The argument clause contains a forward-path and may contain 1686 optional parameters. 1688 The forward-path normally consists of the required destination 1689 mailbox. Sending systems SHOULD NOT generate the optional list of 1690 hosts known as a source route. Receiving systems MUST recognize 1691 source route syntax but SHOULD strip off the source route 1692 specification and utilize the domain name associated with the mailbox 1693 as if the source route had not been provided. 1695 Similarly, relay hosts SHOULD strip or ignore source routes, and 1696 names MUST NOT be copied into the reverse-path. When mail reaches 1697 its ultimate destination (the forward-path contains only a 1698 destination mailbox), the SMTP server inserts it into the destination 1699 mailbox in accordance with its host mail conventions. 1701 This command appends its forward-path argument to the forward-path 1702 buffer; it does not change the reverse-path buffer nor the mail data 1703 buffer. 1705 For example, mail received at relay host xyz.com with envelope 1706 commands 1708 MAIL FROM: 1709 RCPT TO:<@hosta.int,@jkl.org:userc@d.bar.org> 1711 will normally be sent directly on to host d.bar.org with envelope 1712 commands 1714 MAIL FROM: 1715 RCPT TO: 1717 As provided in Appendix C, xyz.com MAY also choose to relay the 1718 message to hosta.int, using the envelope commands 1720 MAIL FROM: 1721 RCPT TO:<@hosta.int,@jkl.org:userc@d.bar.org> 1723 or to jkl.org, using the envelope commands 1725 MAIL FROM: 1726 RCPT TO:<@jkl.org:userc@d.bar.org> 1728 Attempting to use relaying this way is now strongly discouraged. 1729 Since hosts are not required to relay mail at all, xyz.com MAY also 1730 reject the message entirely when the RCPT command is received, using 1731 a 550 code (since this is a "policy reason"). 1733 If service extensions were negotiated, the RCPT command may also 1734 carry parameters associated with a particular service extension 1735 offered by the server. The client MUST NOT transmit parameters other 1736 than those associated with a service extension offered by the server 1737 in its EHLO response. 1739 Syntax: 1741 rcpt = "RCPT TO:" ( "" / "" / 1742 Forward-path ) [SP Rcpt-parameters] CRLF 1744 Note that, in a departure from the usual rules for 1745 local-parts, the "Postmaster" string shown above is 1746 treated as case-insensitive. 1748 4.1.1.4. DATA (DATA) 1750 The receiver normally sends a 354 response to DATA, and then treats 1751 the lines (strings ending in sequences, as described in 1752 Section 2.3.7) following the command as mail data from the sender. 1753 This command causes the mail data to be appended to the mail data 1754 buffer. The mail data may contain any of the 128 ASCII character 1755 codes, although experience has indicated that use of control 1756 characters other than SP, HT, CR, and LF may cause problems and 1757 SHOULD be avoided when possible. 1759 The mail data are terminated by a line containing only a period, that 1760 is, the character sequence ".", where the first is 1761 actually the terminator of the previous line (see Section 4.5.2). 1762 This is the end of mail data indication. The first of this 1763 terminating sequence is also the that ends the final line of 1764 the data (message text) or, if there was no mail data, ends the DATA 1765 command itself (the "no mail data" case does not conform to this 1766 specification since it would require that neither the trace header 1767 fields required by this specification nor the message header section 1768 required by RFC 5322 [11] be transmitted). An extra MUST NOT 1769 be added, as that would cause an empty line to be added to the 1770 message. The only exception to this rule would arise if the message 1771 body were passed to the originating SMTP-sender with a final "line" 1772 that did not end in ; in that case, the originating SMTP system 1773 MUST either reject the message as invalid or add in order to 1774 have the receiving SMTP server recognize the "end of data" condition. 1776 The custom of accepting lines ending only in , as a concession to 1777 non-conforming behavior on the part of some UNIX systems, has proven 1778 to cause more interoperability problems than it solves, and SMTP 1779 server systems MUST NOT do this, even in the name of improved 1780 robustness. In particular, the sequence "." (bare line 1781 feeds, without carriage returns) MUST NOT be treated as equivalent to 1782 . as the end of mail data indication. 1784 Receipt of the end of mail data indication requires the server to 1785 process the stored mail transaction information. This processing 1786 consumes the information in the reverse-path buffer, the forward-path 1787 buffer, and the mail data buffer, and on the completion of this 1788 command these buffers are cleared. If the processing is successful, 1789 the receiver MUST send an OK reply. If the processing fails, the 1790 receiver MUST send a failure reply. The SMTP model does not allow 1791 for partial failures at this point: either the message is accepted by 1792 the server for delivery and a positive response is returned or it is 1793 not accepted and a failure reply is returned. In sending a positive 1794 "250 OK" completion reply to the end of data indication, the receiver 1795 takes full responsibility for the message (see Section 6.1). Errors 1796 that are diagnosed subsequently MUST be reported in a mail message, 1797 as discussed in Section 4.4. 1799 When the SMTP server accepts a message either for relaying or for 1800 final delivery, it inserts a trace record (also referred to 1801 interchangeably as a "time stamp line" or "Received" line) at the top 1802 of the mail data. This trace record indicates the identity of the 1803 host that sent the message, the identity of the host that received 1804 the message (and is inserting this time stamp), and the date and time 1805 the message was received. Relayed messages will have multiple time 1806 stamp lines. Details for formation of these lines, including their 1807 syntax, is specified in Section 4.4. 1809 Additional discussion about the operation of the DATA command appears 1810 in Section 3.3. 1812 Syntax: 1814 data = "DATA" CRLF 1816 4.1.1.5. RESET (RSET) 1818 This command specifies that the current mail transaction will be 1819 aborted. Any stored sender, recipients, and mail data MUST be 1820 discarded, and all buffers and state tables cleared. The receiver 1821 MUST send a "250 OK" reply to a RSET command with no arguments. A 1822 reset command may be issued by the client at any time. It is 1823 effectively equivalent to a NOOP (i.e., it has no effect) if issued 1824 immediately after EHLO, before EHLO is issued in the session, after 1825 an end of data indicator has been sent and acknowledged, or 1826 immediately before a QUIT. An SMTP server MUST NOT close the 1827 connection as the result of receiving a RSET; that action is reserved 1828 for QUIT (see Section 4.1.1.10). 1830 Since EHLO implies some additional processing and response by the 1831 server, RSET will normally be more efficient than reissuing that 1832 command, even though the formal semantics are the same. 1834 There are circumstances, contrary to the intent of this 1835 specification, in which an SMTP server may receive an indication that 1836 the underlying TCP connection has been closed or reset. To preserve 1837 the robustness of the mail system, SMTP servers SHOULD be prepared 1838 for this condition and SHOULD treat it as if a QUIT had been received 1839 before the connection disappeared. 1841 Syntax: 1843 rset = "RSET" CRLF 1845 4.1.1.6. VERIFY (VRFY) 1847 This command asks the receiver to confirm that the argument 1848 identifies a user or mailbox. If it is a user name, information is 1849 returned as specified in Section 3.5. 1851 This command has no effect on the reverse-path buffer, the forward- 1852 path buffer, or the mail data buffer. 1854 Syntax: 1856 vrfy = "VRFY" SP String CRLF 1858 4.1.1.7. EXPAND (EXPN) 1860 This command asks the receiver to confirm that the argument 1861 identifies a mailing list, and if so, to return the membership of 1862 that list. If the command is successful, a reply is returned 1863 containing information as described in Section 3.5. This reply will 1864 have multiple lines except in the trivial case of a one-member list. 1866 This command has no effect on the reverse-path buffer, the forward- 1867 path buffer, or the mail data buffer, and it may be issued at any 1868 time. 1870 Syntax: 1872 expn = "EXPN" SP String CRLF 1874 4.1.1.8. HELP (HELP) 1876 This command causes the server to send helpful information to the 1877 client. The command MAY take an argument (e.g., any command name) 1878 and return more specific information as a response. 1880 This command has no effect on the reverse-path buffer, the forward- 1881 path buffer, or the mail data buffer, and it may be issued at any 1882 time. 1884 SMTP servers SHOULD support HELP without arguments and MAY support it 1885 with arguments. 1887 Syntax: 1889 help = "HELP" [ SP String ] CRLF 1891 4.1.1.9. NOOP (NOOP) 1893 This command does not affect any parameters or previously entered 1894 commands. It specifies no action other than that the receiver send a 1895 "250 OK" reply. 1897 This command has no effect on the reverse-path buffer, the forward- 1898 path buffer, or the mail data buffer, and it may be issued at any 1899 time. If a parameter string is specified, servers SHOULD ignore it. 1901 Syntax: 1903 noop = "NOOP" [ SP String ] CRLF 1905 4.1.1.10. QUIT (QUIT) 1907 This command specifies that the receiver MUST send a "221 OK" reply, 1908 and then close the transmission channel. 1910 The receiver MUST NOT intentionally close the transmission channel 1911 until it receives and replies to a QUIT command (even if there was an 1912 error). The sender MUST NOT intentionally close the transmission 1913 channel until it sends a QUIT command, and it SHOULD wait until it 1914 receives the reply (even if there was an error response to a previous 1915 command). If the connection is closed prematurely due to violations 1916 of the above or system or network failure, the server MUST cancel any 1917 pending transaction, but not undo any previously completed 1918 transaction, and generally MUST act as if the command or transaction 1919 in progress had received a temporary error (i.e., a 4yz response). 1921 The QUIT command may be issued at any time. Any current uncompleted 1922 mail transaction will be aborted. 1924 Syntax: 1926 quit = "QUIT" CRLF 1928 4.1.1.11. Mail-Parameter and Rcpt-Parameter Error Responses 1930 If the server SMTP does not recognize or cannot implement one or more 1931 of the parameters associated with a particular MAIL FROM or RCPT TO 1932 command, it will return code 555. 1934 If, for some reason, the server is temporarily unable to accommodate 1935 one or more of the parameters associated with a MAIL FROM or RCPT TO 1936 command, and if the definition of the specific parameter does not 1937 mandate the use of another code, it should return code 455. 1939 Errors specific to particular parameters and their values will be 1940 specified in the parameter's defining RFC. 1942 4.1.2. Command Argument Syntax 1944 The syntax of the argument clauses of the above commands (using the 1945 syntax specified in RFC 5234 [5] where applicable) is given below. 1946 Some of the productions given below are used only in conjunction with 1947 source routes as described in Appendix C. Terminals not defined in 1948 this document, such as ALPHA, DIGIT, SP, CR, LF, CRLF, are as defined 1949 in the "core" syntax in Appendix B of RFC 5234 [5] or in the message 1950 format syntax in RFC 5322 [11]. 1952 Reverse-path = Path / "<>" 1954 Forward-path = Path 1956 Path = "<" [ A-d-l ":" ] Mailbox ">" 1957 A-d-l = At-domain *( "," At-domain ) 1958 ; Note that this form, the so-called "source 1959 ; route", MUST BE accepted, SHOULD NOT be 1960 ; generated, and SHOULD be ignored. 1962 At-domain = "@" Domain 1964 Mail-parameters = esmtp-param *(SP esmtp-param) 1966 Rcpt-parameters = esmtp-param *(SP esmtp-param) 1968 esmtp-param = esmtp-keyword ["=" esmtp-value] 1970 esmtp-keyword = (ALPHA / DIGIT) *(ALPHA / DIGIT / "-") 1972 esmtp-value = 1*(%d33-60 / %d62-126) 1973 ; any CHAR excluding "=", SP, and control 1974 ; characters. If this string is an email address, 1975 ; i.e., a Mailbox, then the "xtext" syntax [12] 1976 ; SHOULD be used. 1978 Keyword = Ldh-str 1980 Argument = Atom 1982 Domain = sub-domain *("." sub-domain) 1984 sub-domain = Let-dig [Ldh-str] 1986 Let-dig = ALPHA / DIGIT 1988 Ldh-str = *( ALPHA / DIGIT / "-" ) Let-dig 1990 address-literal = "[" ( IPv4-address-literal / 1991 IPv6-address-literal / 1992 General-address-literal ) "]" 1993 ; See Section 4.1.3 1995 Mailbox = Local-part "@" ( Domain / address-literal ) 1997 Local-part = Dot-string / Quoted-string 1998 ; MAY be case-sensitive 2000 Dot-string = Atom *("." Atom) 2002 Atom = 1*atext 2003 Quoted-string = DQUOTE 1*QcontentSMTP DQUOTE 2005 QcontentSMTP = qtextSMTP / quoted-pairSMTP 2007 quoted-pairSMTP = %d92 %d32-126 2008 ; i.e., backslash followed by any ASCII 2009 ; graphic (including itself) or SPace 2011 qtextSMTP = %d32-33 / %d35-91 / %d93-126 2012 ; i.e., within a quoted string, any 2013 ; ASCII graphic or space is permitted 2014 ; without blackslash-quoting except 2015 ; double-quote and the backslash itself. 2017 String = Atom / Quoted-string 2019 While the above definition for Local-part is relatively permissive, 2020 for maximum interoperability, a host that expects to receive mail 2021 SHOULD avoid defining mailboxes where the Local-part requires (or 2022 uses) the Quoted-string form or where the Local-part is case- 2023 sensitive. For any purposes that require generating or comparing 2024 Local-parts (e.g., to specific mailbox names), all quoted forms MUST 2025 be treated as equivalent, and the sending system SHOULD transmit the 2026 form that uses the minimum quoting possible. 2028 Systems MUST NOT define mailboxes in such a way as to require the use 2029 in SMTP of non-ASCII characters (octets with the high order bit set 2030 to one) or ASCII "control characters" (decimal value 0-31 and 127). 2031 These characters MUST NOT be used in MAIL or RCPT commands or other 2032 commands that require mailbox names. 2034 Note that the backslash, "\", is a quote character, which is used to 2035 indicate that the next character is to be used literally (instead of 2036 its normal interpretation). For example, "Joe\,Smith" indicates a 2037 single nine-character user name string with the comma being the 2038 fourth character of that string. 2040 To promote interoperability and consistent with long-standing 2041 guidance about conservative use of the DNS in naming and applications 2042 (e.g., see Section 2.3.1 of the base DNS document, RFC 1035 [7]), 2043 characters outside the set of alphabetic characters, digits, and 2044 hyphen MUST NOT appear in domain name labels for SMTP clients or 2045 servers. In particular, the underscore character is not permitted. 2046 SMTP servers that receive a command in which invalid character codes 2047 have been employed, and for which there are no other reasons for 2048 rejection, MUST reject that command with a 501 response (this rule, 2049 like others, could be overridden by appropriate SMTP extensions). 2051 4.1.3. Address Literals 2053 Sometimes a host is not known to the domain name system and 2054 communication (and, in particular, communication to report and repair 2055 the error) is blocked. To bypass this barrier, a special literal 2056 form of the address is allowed as an alternative to a domain name. 2057 For IPv4 addresses, this form uses four small decimal integers 2058 separated by dots and enclosed by brackets such as [123.255.37.2], 2059 which indicates an (IPv4) Internet Address in sequence-of-octets 2060 form. For IPv6 and other forms of addressing that might eventually 2061 be standardized, the form consists of a standardized "tag" that 2062 identifies the address syntax, a colon, and the address itself, in a 2063 format specified as part of the relevant standards (i.e., RFC 4291 2064 [6] for IPv6). 2065 [[CREF10: [5321bis] Proposed erratum 4315 (2015-03-27) suggests yet 2066 another modification to the IPv6 address literal syntax, based on 2067 part on RFC 5952. We should consider whether those, or other, 2068 modifications are appropriate and/or whether, given both the issues 2069 of spam/malware and servers supporting multiple domains, it it time 2070 to deprecate mailboxes containing address literals entirely (EHLO 2071 fields may be a different issue). If we are going to allow IPv6 2072 address literals, it may be time to incorporate something by 2073 reference rather than including specific syntax here (RFC 5952 is 14 2074 pages long and does not contain any ABNF).]] 2076 Specifically: 2078 IPv4-address-literal = Snum 3("." Snum) 2080 IPv6-address-literal = "IPv6:" IPv6-addr 2082 General-address-literal = Standardized-tag ":" 1*dcontent 2084 Standardized-tag = Ldh-str 2085 ; Standardized-tag MUST be specified in a 2086 ; Standards-Track RFC and registered with IANA 2088 dcontent = %d33-90 / ; Printable US-ASCII 2089 %d94-126 ; excl. "[", "\", "]" 2091 Snum = 1*3DIGIT 2092 ; representing a decimal integer 2093 ; value in the range 0 through 255 2095 IPv6-addr = 6( h16 ":" ) ls32 2096 / "::" 5( h16 ":" ) ls32 2097 / [ h16 ] "::" 4( h16 ":" ) ls32 2098 / [ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32 2099 / [ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32 2100 / [ *3( h16 ":" ) h16 ] "::" h16 ":" ls32 2101 / [ *4( h16 ":" ) h16 ] "::" ls32 2102 / [ *5( h16 ":" ) h16 ] "::" h16 2103 / [ *6( h16 ":" ) h16 ] "::" 2104 ; This definition is consistent with the one for 2105 ; URIs [47]. 2107 ls32 = ( h16 ":" h16 ) / IPv4address 2108 ; least-significant 32 bits of address 2110 h16 = 1*4HEXDIG 2111 ; 16 bits of address represented in hexadecimal 2112 [[CREF11: [5321bis](2821ter) 2821bis Last Call 2113 comment]] 2115 4.1.4. Order of Commands 2117 There are restrictions on the order in which these commands may be 2118 used. 2120 A session that will contain mail transactions MUST first be 2121 initialized by the use of the EHLO command. An SMTP server SHOULD 2122 accept commands for non-mail transactions (e.g., VRFY, EXPN, or NOOP) 2123 without this initialization. 2125 An EHLO command MAY be issued by a client later in the session. If 2126 it is issued after the session begins and the EHLO command is 2127 acceptable to the SMTP server, the SMTP server MUST clear all buffers 2128 and reset the state exactly as if a RSET command had been issued. In 2129 other words, the sequence of RSET followed immediately by EHLO is 2130 redundant, but not harmful other than in the performance cost of 2131 executing unnecessary commands. 2133 If the EHLO command is not acceptable to the SMTP server, 501, 500, 2134 502, or 550 failure replies MUST be returned as appropriate. The 2135 SMTP server MUST stay in the same state after transmitting these 2136 replies that it was in before the EHLO was received. 2138 The SMTP client MUST, if possible, ensure that the domain parameter 2139 to the EHLO command is a primary host name as specified for this 2140 command in Section 2.3.5. If this is not possible (e.g., when the 2141 client's address is dynamically assigned and the client does not have 2142 an obvious name), an address literal SHOULD be substituted for the 2143 domain name. 2145 An SMTP server MAY verify that the domain name argument in the EHLO 2146 command actually corresponds to the IP address of the client. 2148 [[CREF12: [5321bis] [[Note in draft -- proposed change to "An SMTP 2149 server MAY verify that the domain name argument in the EHLO command 2150 has an address record matching the IP address of the client." --David 2151 MacQuigg, david_macquigg@yahoo.com, Friday, 20090130 0637 -0700]]]] 2152 However, if the verification fails, the server MUST NOT refuse to 2153 accept a message on that basis. Information captured in the 2154 verification attempt is for logging and tracing purposes. Note that 2155 this prohibition applies to the matching of the parameter to its IP 2156 address only; see Section 7.9 for a more extensive discussion of 2157 rejecting incoming connections or mail messages. 2159 The NOOP, HELP, EXPN, VRFY, and RSET commands can be used at any time 2160 during a session, or without previously initializing a session. SMTP 2161 servers SHOULD process these normally (that is, not return a 503 2162 code) even if no EHLO command has yet been received; clients SHOULD 2163 open a session with EHLO before sending these commands. 2165 If these rules are followed, the example in RFC 821 that shows "550 2166 access denied to you" in response to an EXPN command is incorrect 2167 unless an EHLO command precedes the EXPN or the denial of access is 2168 based on the client's IP address or other authentication or 2169 authorization-determining mechanisms. 2171 The MAIL command (or the obsolete SEND, SOML, or SAML commands) 2172 [[5321bis Editor's Note: is there any reason to not clean those 2173 commands out of this entirely, replacing them with, e.g., a strong 2174 reference to Appendix F.6]] 2175 begins a mail transaction. Once started, a mail transaction consists 2176 of a transaction beginning command, one or more RCPT commands, and a 2177 DATA command, in that order. A mail transaction may be aborted by 2178 the RSET, a new EHLO, or the QUIT command. There may be zero or more 2179 transactions in a session. MAIL (or SEND, SOML, or SAML) MUST NOT be 2180 sent if a mail transaction is already open, i.e., it should be sent 2181 only if no mail transaction had been started in the session, or if 2182 the previous one successfully concluded with a successful DATA 2183 command, or if the previous one was aborted, e.g., with a RSET or new 2184 EHLO. [[CREF13: [5321bis] 2821ter note: see comment about changing 2185 this convoluted discussion to talk about 'mail transaction' above. 2186 --Jck]] 2188 If the transaction beginning command argument is not acceptable, a 2189 501 failure reply MUST be returned and the SMTP server MUST stay in 2190 the same state. If the commands in a transaction are out of order to 2191 the degree that they cannot be processed by the server, a 503 failure 2192 reply MUST be returned and the SMTP server MUST stay in the same 2193 state. 2195 The last command in a session MUST be the QUIT command. The QUIT 2196 command SHOULD be used by the client SMTP to request connection 2197 closure, even when no session opening command was sent and accepted. 2199 4.1.5. Private-Use Commands 2201 As specified in Section 2.2.2, commands starting in "X" may be used 2202 by bilateral agreement between the client (sending) and server 2203 (receiving) SMTP agents. An SMTP server that does not recognize such 2204 a command is expected to reply with "500 Command not recognized". An 2205 extended SMTP server MAY list the feature names associated with these 2206 private commands in the response to the EHLO command. 2208 Commands sent or accepted by SMTP systems that do not start with "X" 2209 MUST conform to the requirements of Section 2.2.2. 2211 4.2. SMTP Replies 2213 Replies to SMTP commands serve to ensure the synchronization of 2214 requests and actions in the process of mail transfer and to guarantee 2215 that the SMTP client always knows the state of the SMTP server. 2216 Every command MUST generate exactly one reply. 2218 The details of the command-reply sequence are described in 2219 Section 4.3. 2221 An SMTP reply consists of a three digit number (transmitted as three 2222 numeric characters) followed by some text unless specified otherwise 2223 in this document. The number is for use by automata to determine 2224 what state to enter next; the text is for the human user. The three 2225 digits contain enough encoded information that the SMTP client need 2226 not examine the text and may either discard it or pass it on to the 2227 user, as appropriate. Exceptions are as noted elsewhere in this 2228 document. In particular, the 220, 221, 251, 421, and 551 reply codes 2229 are associated with message text that must be parsed and interpreted 2230 by machines. In the general case, the text may be receiver dependent 2231 and context dependent, so there are likely to be varying texts for 2232 each reply code. A discussion of the theory of reply codes is given 2233 in Section 4.2.1. Formally, a reply is defined to be the sequence: a 2234 three-digit code, , one line of text, and , or a multiline 2235 reply (as defined in the same section). Since, in violation of this 2236 specification, the text is sometimes not sent, clients that do not 2237 receive it SHOULD be prepared to process the code alone (with or 2238 without a trailing space character). Only the EHLO, EXPN, and HELP 2239 commands are expected to result in multiline replies in normal 2240 circumstances; however, multiline replies are allowed for any 2241 command. 2243 In ABNF, server responses are: 2245 Greeting = ( "220 " (Domain / address-literal) 2246 [ SP textstring ] CRLF ) / 2247 ( "220-" (Domain / address-literal) 2248 [ SP textstring ] CRLF 2249 *( "220-" [ textstring ] CRLF ) 2250 "220" [ SP textstring ] CRLF ) 2252 textstring = 1*(%d09 / %d32-126) ; HT, SP, Printable US-ASCII 2254 Reply-line = *( Reply-code "-" [ textstring ] CRLF ) 2255 Reply-code [ SP textstring ] CRLF 2257 Reply-code = %x32-35 %x30-35 %x30-39 2259 where "Greeting" appears only in the 220 response that announces that 2260 the server is opening its part of the connection. (Other possible 2261 server responses upon connection follow the syntax of Reply-line.) 2263 An SMTP server SHOULD send only the reply codes listed in this 2264 document or additions to the list as discussed below. 2265 [[CREF14: [5321bis] 20140804: New text to clear up ambiguity.]] 2266 An SMTP server SHOULD use the text shown in the examples whenever 2267 appropriate. 2269 An SMTP client MUST determine its actions only by the reply code, not 2270 by the text (except for the "change of address" 251 and 551 and, if 2271 necessary, 220, 221, and 421 replies); in the general case, any text, 2272 including no text at all (although senders SHOULD NOT send bare 2273 codes), MUST be acceptable. The space (blank) following the reply 2274 code is considered part of the text. Whenever possible, a sender- 2275 SMTP SHOULD test the first digit (severity indication) of a reply 2276 code it receives. 2277 [[CREF15: [5321bis] 20141209 [[Note in Draft: What is that sentence 2278 supposed to be tell us? Test the first digit and examine the others 2279 only if necessary? Note the interaction between this and various 2280 flaps about adding new codes.]]]] 2282 The list of codes that appears below MUST NOT be construed as 2283 permanent. While the addition of new codes should be a rare and 2284 significant activity, with supplemental information in the textual 2285 part of the response (including enhanced status codes [38] and the 2286 successors to that specification) 2287 [[CREF16: [5321bis] 20140802: New text for clarity]] 2288 being preferred, new codes may be added as the result of new 2289 Standards or Standards-Track specifications. Consequently, a sender- 2290 SMTP MUST be prepared to handle codes not specified in this document 2291 and MUST do so by interpreting the first digit only. 2293 In the absence of extensions negotiated with the client, SMTP servers 2294 MUST NOT send reply codes whose first digits are other than 2, 3, 4, 2295 or 5. Clients that receive such out-of-range codes SHOULD normally 2296 treat them as fatal errors and terminate the mail transaction. 2298 4.2.1. Reply Code Severities and Theory 2300 The three digits of the reply each have a special significance. The 2301 first digit denotes whether the response is good, bad, or incomplete. 2302 An unsophisticated SMTP client, or one that receives an unexpected 2303 code, will be able to determine its next action (proceed as planned, 2304 redo, retrench, etc.) by examining this first digit. An SMTP client 2305 that wants to know approximately what kind of error occurred (e.g., 2306 mail system error, command syntax error) may examine the second 2307 digit. The third digit and any supplemental information that may be 2308 present is reserved for the finest gradation of information. 2310 There are four values for the first digit of the reply code: 2312 2yz Positive Completion reply 2313 The requested action has been successfully completed. A new 2314 request may be initiated. 2316 3yz Positive Intermediate reply 2317 The command has been accepted, but the requested action is being 2318 held in abeyance, pending receipt of further information. The 2319 SMTP client should send another command specifying this 2320 information. This reply is used in command sequence groups (i.e., 2321 in DATA). 2323 4yz Transient Negative Completion reply 2324 The command was not accepted, and the requested action did not 2325 occur. However, the error condition is temporary, and the action 2326 may be requested again. The sender should return to the beginning 2327 of the command sequence (if any). It is difficult to assign a 2328 meaning to "transient" when two different sites (receiver- and 2329 sender-SMTP agents) must agree on the interpretation. Each reply 2330 in this category might have a different time value, but the SMTP 2331 client SHOULD try again. A rule of thumb to determine whether a 2332 reply fits into the 4yz or the 5yz category (see below) is that 2333 replies are 4yz if they can be successful if repeated without any 2334 change in command form or in properties of the sender or receiver 2335 (that is, the command is repeated identically and the receiver 2336 does not put up a new implementation). 2338 5yz Permanent Negative Completion reply 2339 The command was not accepted and the requested action did not 2340 occur. The SMTP client SHOULD NOT repeat the exact request (in 2341 the same sequence). Even some "permanent" error conditions can be 2342 corrected, so the human user may want to direct the SMTP client to 2343 reinitiate the command sequence by direct action at some point in 2344 the future (e.g., after the spelling has been changed, or the user 2345 has altered the account status). 2347 It is worth noting that the file transfer protocol (FTP) [18] uses a 2348 very similar code architecture and that the SMTP codes are based on 2349 the FTP model. However, SMTP uses a one-command, one-response model 2350 (while FTP is asynchronous) and FTP's 1yz codes are not part of the 2351 SMTP model. 2353 The second digit encodes responses in specific categories: 2355 x0z Syntax: These replies refer to syntax errors, syntactically 2356 correct commands that do not fit any functional category, and 2357 unimplemented or superfluous commands. 2359 x1z Information: These are replies to requests for information, such 2360 as status or help. 2362 x2z Connections: These are replies referring to the transmission 2363 channel. 2365 x3z Unspecified. 2367 x4z Unspecified. 2369 x5z Mail system: These replies indicate the status of the receiver 2370 mail system vis-a-vis the requested transfer or other mail system 2371 action. 2373 The third digit gives a finer gradation of meaning in each category 2374 specified by the second digit. The list of replies illustrates this. 2375 Each reply text is recommended rather than mandatory, and may even 2376 change according to the command with which it is associated. On the 2377 other hand, the reply codes must strictly follow the specifications 2378 in this section. Receiver implementations should not invent new 2379 codes for slightly different situations from the ones described here, 2380 but rather adapt codes already defined. 2382 For example, a command such as NOOP, whose successful execution does 2383 not offer the SMTP client any new information, will return a 250 2384 reply. The reply is 502 when the command requests an unimplemented 2385 non-site-specific action. A refinement of that is the 504 reply for 2386 a command that is implemented, but that requests an unimplemented 2387 parameter. 2389 The reply text may be longer than a single line; in these cases the 2390 complete text must be marked so the SMTP client knows when it can 2391 stop reading the reply. This requires a special format to indicate a 2392 multiple line reply. 2394 The format for multiline replies requires that every line, except the 2395 last, begin with the reply code, followed immediately by a hyphen, 2396 "-" (also known as minus), followed by text. The last line will 2397 begin with the reply code, followed immediately by , optionally 2398 some text, and . As noted above, servers SHOULD send the 2399 if subsequent text is not sent, but clients MUST be prepared for it 2400 to be omitted. 2402 For example: 2404 250-First line 2405 250-Second line 2406 250-234 Text beginning with numbers 2407 250 The last line 2409 In a multiline reply, the reply code on each of the lines MUST be the 2410 same. It is reasonable for the client to rely on this, so it can 2411 make processing decisions based on the code in any line, assuming 2412 that all others will be the same. In a few cases, there is important 2413 data for the client in the reply "text". The client will be able to 2414 identify these cases from the current context. 2416 4.2.2. Reply Codes by Function Groups 2418 500 Syntax error, command unrecognized (This may include errors such 2419 as command line too long) 2421 501 Syntax error in parameters or arguments 2423 502 Command not implemented (see Section 4.2.4.1) 2425 503 Bad sequence of commands 2427 504 Command parameter not implemented 2429 211 System status, or system help reply 2430 214 Help message (Information on how to use the receiver or the 2431 meaning of a particular non-standard command; this reply is useful 2432 only to the human user) 2434 220 Service ready 2436 221 Service closing transmission channel 2438 421 Service not available, closing transmission channel 2439 (This may be a reply to any command if the service knows it must 2440 shut down) 2442 hangText="521"> No mail service here. [[CREF17: 2443 [5321bis]20140804: Specific code introduced with RFC 1846, updated 2444 and specified in draft-klensin-smtp-521code.]] 2446 556 No mail service at this domain. [[CREF18: [5321bis] 20140912: 2447 Specific code introduced in draft-klensin-smtp-521code-02, largely 2448 for nullMX]] 2450 250 Requested mail action okay, completed 2452 251 User not local; will forward to (See Section 3.4) 2454 252 Cannot VRFY user, but will accept message and attempt delivery 2455 (See Section 3.5.3) 2457 455 Server unable to accommodate parameters 2459 555 MAIL FROM/RCPT TO parameters not recognized or not implemented 2461 450 Requested mail action not taken: mailbox unavailable (e.g., 2462 mailbox busy or temporarily blocked for policy reasons) 2464 550 Requested action not taken: mailbox unavailable (e.g., mailbox 2465 not found, no access, or command rejected for policy reasons) 2467 451 Requested action aborted: error in processing 2469 551 User not local; please try (See Section 3.4) 2471 452 Requested action not taken: insufficient system storage 2473 552 Requested mail action aborted: exceeded storage allocation 2474 553 Requested action not taken: mailbox name not allowed (e.g., 2475 mailbox syntax incorrect) 2477 354 Start mail input; end with . 2479 554 Transaction failed (Or, in the case of a connection-opening 2480 response, "No SMTP service here") 2481 [[CREF19: [5321bis] [[Note in Draft: Revise above statement in the 2482 light of new 521 code??]] ]] 2484 4.2.3. Reply Codes in Numeric Order 2486 211 System status, or system help reply 2488 214 Help message (Information on how to use the receiver or the 2489 meaning of a particular non-standard command; this reply is useful 2490 only to the human user) 2492 220 Service ready 2494 221 Service closing transmission channel 2496 250 Requested mail action okay, completed 2498 251 User not local; will forward to (See Section 3.4) 2500 252 Cannot VRFY user, but will accept message and attempt delivery 2501 (See Section 3.5.3) 2503 354 Start mail input; end with . 2505 421 Service not available, closing transmission channel 2506 (This may be a reply to any command if the service knows it must 2507 shut down) 2509 450 Requested mail action not taken: mailbox unavailable (e.g., 2510 mailbox busy or temporarily blocked for policy reasons) 2512 451 Requested action aborted: local error in processing 2514 452 Requested action not taken: insufficient system storage 2516 455 Server unable to accommodate parameters 2517 500 Syntax error, command unrecognized (This may include errors such 2518 as command line too long) 2520 501 Syntax error in parameters or arguments 2522 502 Command not implemented (see Section 4.2.4.1) 2524 503 Bad sequence of commands 2526 504 Command parameter not implemented 2528 521 No mail service 2530 550 Requested action not taken: mailbox unavailable (e.g., mailbox 2531 not found, no access, or command rejected for policy reasons) 2533 551 User not local; please try (See Section 3.4) 2535 552 Requested mail action aborted: exceeded storage allocation 2537 553 Requested action not taken: mailbox name not allowed (e.g., 2538 mailbox syntax incorrect) 2540 554 Transaction failed (Or, in the case of a connection-opening 2541 response, "No SMTP service here") 2543 555 MAIL FROM/RCPT TO parameters not recognized or not implemented 2545 556 No mail service at this domain. 2547 4.2.4. Some specific code situations and relationships 2549 4.2.4.1. Reply Code 502 2551 Questions have been raised as to when reply code 502 (Command not 2552 implemented) SHOULD be returned in preference to other codes. 502 2553 SHOULD be used when the command is actually recognized by the SMTP 2554 server, but not implemented. If the command is not recognized, code 2555 500 SHOULD be returned. Extended SMTP systems MUST NOT list 2556 capabilities in response to EHLO for which they will return 502 (or 2557 500) replies. 2559 4.2.4.2. "No mail accepted" situations and the 521, 554, and 556 codes 2561 [[CREF20: [5321bis] This section is new with 5321bis. ]] 2563 Codes 521, 554, and 556 are all used to report different types of "no 2564 mail accepted" situations. They differ as follows. 521 is an 2565 indication from a system answering on the SMTP port that it does not 2566 support SMTP service (a so-called "dummy server" as discussed in RFC 2567 1846 [24] and elsewhere). Obviously, it requires that system exist 2568 and that a connection can be made successfully to it. Because a 2569 system that does not accept any mail cannot meaningfully accept a 2570 RCPT command, any commands (other than QUIT) issued after an SMTP 2571 server has issued a 521 reply are client (sender) errors. 556 is 2572 used by a message submission or intermediate SMTP system (see 2573 Section 1.1) to report that it cannot forward the message further 2574 because it knows (e.g., from a DNS entry [51]) that the recipient 2575 domain does not accept mail. It would normally be used in response 2576 to a RCPT or similar (extension) command when the SMTP system 2577 identifies a domain that it can (or has) determined never accepts 2578 mail. Other codes, including 554 and the temporary 450, are used for 2579 more transient situations and situations in which an SMTP server 2580 cannot or will not deliver to (or accept mail for) a particular 2581 system or mailbox for policy reasons rather than ones directly 2582 related to SMTP processing. 2584 4.2.4.3. Reply Codes after DATA and the Subsequent . 2586 When an SMTP server returns a positive completion status (2yz code) 2587 after the DATA command is completed with ., it accepts 2588 responsibility for: 2590 o delivering the message (if the recipient mailbox exists), or 2592 o if attempts to deliver the message fail due to transient 2593 conditions, retrying delivery some reasonable number of times at 2594 intervals as specified in Section 4.5.4. 2596 o if attempts to deliver the message fail due to permanent 2597 conditions, or if repeated attempts to deliver the message fail 2598 due to transient conditions, returning appropriate notification to 2599 the sender of the original message (using the address in the SMTP 2600 MAIL command). 2602 When an SMTP server returns a temporary error status (4yz) code after 2603 the DATA command is completed with ., it MUST NOT make a 2604 subsequent attempt to deliver that message. The SMTP client retains 2605 responsibility for the delivery of that message and may either return 2606 it to the user or requeue it for a subsequent attempt (see 2607 Section 4.5.4.1). 2609 The user who originated the message SHOULD be able to interpret the 2610 return of a transient failure status (by mail message or otherwise) 2611 as a non-delivery indication, just as a permanent failure would be 2612 interpreted. If the client SMTP successfully handles these 2613 conditions, the user will not receive such a reply. 2615 When an SMTP server returns a permanent error status (5yz) code after 2616 the DATA command is completed with ., it MUST NOT make 2617 any subsequent attempt to deliver the message. As with temporary 2618 error status codes, the SMTP client retains responsibility for the 2619 message, but SHOULD not again attempt delivery to the same server 2620 without user review of the message and response and appropriate 2621 intervention. 2623 4.3. Sequencing of Commands and Replies 2625 4.3.1. Sequencing Overview 2627 The communication between the sender and receiver is an alternating 2628 dialogue, controlled by the sender. As such, the sender issues a 2629 command and the receiver responds with a reply. Unless other 2630 arrangements are negotiated through service extensions, the sender 2631 MUST wait for this response before sending further commands. One 2632 important reply is the connection greeting. Normally, a receiver 2633 will send a 220 "Service ready" reply when the connection is 2634 completed. The sender SHOULD wait for this greeting message before 2635 sending any commands. 2637 Note: all the greeting-type replies have the official name (the 2638 fully-qualified primary domain name) of the server host as the first 2639 word following the reply code. Sometimes the host will have no 2640 meaningful name. See Section 4.1.3 for a discussion of alternatives 2641 in these situations. 2643 For example, 2645 220 ISIF.USC.EDU Service ready 2647 or 2649 220 mail.example.com SuperSMTP v 6.1.2 Service ready 2651 or 2653 220 [10.0.0.1] Clueless host service ready 2655 The table below lists alternative success and failure replies for 2656 each command. These SHOULD be strictly adhered to. A receiver MAY 2657 substitute text in the replies, but the meanings and actions implied 2658 by the code numbers and by the specific command reply sequence MUST 2659 be preserved. However, in order to provide robustness as SMTP is 2660 extended and evolves, the discussion in Section 4.2.1 still applies: 2661 all SMTP clients MUST be prepared to accept any code that conforms to 2662 the discussion in that section and MUST be prepared to interpret it 2663 on the basis of its first digit only. [[CREF21: [5321bis] 20140914: 2664 Above sentence is new text based on yet another round of discussions 2665 about "invalid codes".]] 2667 4.3.2. Command-Reply Sequences 2669 Each command is listed with its usual possible replies. The prefixes 2670 used before the possible replies are "I" for intermediate, "S" for 2671 success, and "E" for error. Since some servers may generate other 2672 replies under special circumstances, and to allow for future 2673 extension, SMTP clients SHOULD, when possible, interpret only the 2674 first digit of the reply and MUST be prepared to deal with 2675 unrecognized reply codes by interpreting the first digit only. 2676 Unless extended using the mechanisms described in Section 2.2, SMTP 2677 servers MUST NOT transmit reply codes to an SMTP client that are 2678 other than three digits or that do not start in a digit between 2 and 2679 5 inclusive. 2681 These sequencing rules and, in principle, the codes themselves, can 2682 be extended or modified by SMTP extensions offered by the server and 2683 accepted (requested) by the client. However, if the target is more 2684 precise granularity in the codes, rather than codes for completely 2685 new purposes, the system described in RFC 3463 [38] SHOULD be used in 2686 preference to the invention of new codes. 2688 In addition to the codes listed below, any SMTP command can return 2689 any of the following codes if the corresponding unusual circumstances 2690 are encountered: 2692 500 For the "command line too long" case or if the command name was 2693 not recognized. Note that producing a "command not recognized" 2694 error in response to the required subset of these commands is a 2695 violation of this specification. Similarly, producing a "command 2696 too long" message for a command line shorter than 512 characters 2697 would violate the provisions of Section 4.5.3.1.4. 2699 501 Syntax error in command or arguments. In order to provide for 2700 future extensions, commands that are specified in this document as 2701 not accepting arguments (DATA, RSET, QUIT) SHOULD return a 501 2702 message if arguments are supplied in the absence of EHLO- 2703 advertised extensions. 2705 421 Service shutting down and closing transmission channel 2707 Specific sequences are: 2709 CONNECTION ESTABLISHMENT 2711 S: 220 2712 E: 521, 554 2714 EHLO or HELO 2716 S: 250 2717 E: 504 (a conforming implementation could return this code only 2718 in fairly obscure cases), 550, 502 (permitted only with an old- 2719 style server that does not support EHLO) 2721 MAIL 2723 S: 250 2724 E: 552, 451, 452, 550, 553, 503, 455, 555 2726 RCPT 2728 S: 250, 251 (but see Section 3.4 for discussion of 251 and 551) 2729 E: 550, 551, 552, 553, 450, 451, 452, 503, 455, 555 2731 DATA 2733 I: 354 -> data -> S: 250 2735 E: 552, 554, 451, 452 2737 E: 450, 550 (rejections for policy reasons) 2739 E: 503, 554 2741 RSET 2743 S: 250 2745 VRFY 2747 S: 250, 251, 252 2748 E: 550, 551, 553, 502, 504 2750 EXPN 2752 S: 250, 252 2753 E: 550, 500, 502, 504 2755 HELP 2756 S: 211, 214 2757 E: 502, 504 2759 NOOP 2761 S: 250 2763 QUIT 2765 S: 221 2767 4.4. Trace Information 2769 When an SMTP server receives a message for delivery or further 2770 processing, it MUST insert trace (often referred to as "time stamp" 2771 or "Received" information) [[CREF22: [5321bis] See note on 2772 rfc5321bis-00c above]] information at the beginning of the message 2773 content, as discussed in Section 4.1.1.4. 2775 This line MUST be structured as follows: 2777 o The FROM clause, which MUST be supplied in an SMTP environment, 2778 SHOULD contain both (1) the name of the source host as presented 2779 in the EHLO command and (2) an address literal containing the IP 2780 address of the source, determined from the TCP connection. 2782 o The ID clause MAY contain an "@" as suggested in RFC 822, but this 2783 is not required. 2785 o If the FOR clause appears, it MUST contain exactly one 2786 entry, even when multiple RCPT commands have been given. Multiple 2787 s raise some security issues and have been deprecated, see 2788 Section 7.2. 2790 An Internet mail program MUST NOT change or delete a Received: line 2791 that was previously added to the message header section. SMTP 2792 servers MUST prepend Received lines to messages; they MUST NOT change 2793 the order of existing lines or insert Received lines in any other 2794 location. 2796 As the Internet grows, comparability of Received header fields is 2797 important for detecting problems, especially slow relays. SMTP 2798 servers that create Received header fields SHOULD use explicit 2799 offsets in the dates (e.g., -0800), rather than time zone names of 2800 any type. Local time (with an offset) SHOULD be used rather than UT 2801 when feasible. This formulation allows slightly more information 2802 about local circumstances to be specified. If UT is needed, the 2803 receiver need merely do some simple arithmetic to convert the values. 2805 Use of UT loses information about the time zone-location of the 2806 server. If it is desired to supply a time zone name, it SHOULD be 2807 included in a comment. 2809 When the delivery SMTP server makes the "final delivery" of a 2810 message, it inserts a return-path line at the beginning of the mail 2811 data. This use of return-path is required; mail systems MUST support 2812 it. The return-path line preserves the information in the from the MAIL command. Here, final delivery means the message 2814 has left the SMTP environment. Normally, this would mean it had been 2815 delivered to the destination user or an associated mail drop, but in 2816 some cases it may be further processed and transmitted by another 2817 mail system. 2819 It is possible for the mailbox in the return path to be different 2820 from the actual sender's mailbox, for example, if error responses are 2821 to be delivered to a special error handling mailbox rather than to 2822 the message sender. When mailing lists are involved, this 2823 arrangement is common and useful as a means of directing errors to 2824 the list maintainer rather than the message originator. 2826 The text above implies that the final mail data will begin with a 2827 return path line, followed by one or more time stamp lines. These 2828 lines will be followed by the rest of the mail data: first the 2829 balance of the mail header section and then the body (RFC 5322 [11]). 2831 It is sometimes difficult for an SMTP server to determine whether or 2832 not it is making final delivery since forwarding or other operations 2833 may occur after the message is accepted for delivery. Consequently, 2834 any further (forwarding, gateway, or relay) systems MAY remove the 2835 return path and rebuild the MAIL command as needed to ensure that 2836 exactly one such line appears in a delivered message. 2838 A message-originating SMTP system SHOULD NOT send a message that 2839 already contains a Return-path header field. SMTP servers performing 2840 a relay function MUST NOT inspect the message data, and especially 2841 not to the extent needed to determine if Return-path header fields 2842 are present. SMTP servers making final delivery MAY remove Return- 2843 path header fields before adding their own. 2845 The primary purpose of the Return-path is to designate the address to 2846 which messages indicating non-delivery or other mail system failures 2847 are to be sent. For this to be unambiguous, exactly one return path 2848 SHOULD be present when the message is delivered. Systems using RFC 2849 822 syntax with non-SMTP transports SHOULD designate an unambiguous 2850 address, associated with the transport envelope, to which error 2851 reports (e.g., non-delivery messages) should be sent. 2853 Historical note: Text in RFC 822 that appears to contradict the use 2854 of the Return-path header field (or the envelope reverse-path address 2855 from the MAIL command) as the destination for error messages is not 2856 applicable on the Internet. The reverse-path address (as copied into 2857 the Return-path) MUST be used as the target of any mail containing 2858 delivery error messages. 2860 In particular: 2862 o a gateway from SMTP -> elsewhere SHOULD insert a return-path 2863 header field, unless it is known that the "elsewhere" transport 2864 also uses Internet domain addresses and maintains the envelope 2865 sender address separately. 2867 o a gateway from elsewhere -> SMTP SHOULD delete any return-path 2868 header field present in the message, and either copy that 2869 information to the SMTP envelope or combine it with information 2870 present in the envelope of the other transport system to construct 2871 the reverse-path argument to the MAIL command in the SMTP 2872 envelope. 2874 The server must give special treatment to cases in which the 2875 processing following the end of mail data indication is only 2876 partially successful. This could happen if, after accepting several 2877 recipients and the mail data, the SMTP server finds that the mail 2878 data could be successfully delivered to some, but not all, of the 2879 recipients. In such cases, the response to the DATA command MUST be 2880 an OK reply. However, the SMTP server MUST compose and send an 2881 "undeliverable mail" notification message to the originator of the 2882 message. 2884 A single notification listing all of the failed recipients or 2885 separate notification messages MUST be sent for each failed 2886 recipient. For economy of processing by the sender, the former 2887 SHOULD be used when possible. Note that the key difference between 2888 handling aliases (Section 3.9.1) and forwarding (this subsection) is 2889 the change to the backward-pointing address in this case. All 2890 notification messages about undeliverable mail MUST be sent using the 2891 MAIL command (even if they result from processing the obsolete SEND, 2892 SOML, or SAML commands) and MUST use a null return path as discussed 2893 in Section 3.6. 2895 The time stamp line and the return path line are formally defined as 2896 follows (the definitions for "FWS" and "CFWS" appear in RFC 5322 2897 [11]): 2899 Return-path-line = "Return-Path:" FWS Reverse-path 2900 Time-stamp-line = "Received:" FWS Stamp 2902 Stamp = From-domain By-domain Opt-info [CFWS] ";" 2903 FWS date-time 2904 ; where "date-time" is as defined in RFC 5322 [11] 2905 ; but the "obs-" forms, especially two-digit 2906 ; years, are prohibited in SMTP and MUST NOT be used. 2908 From-domain = "FROM" FWS Extended-Domain 2910 By-domain = CFWS "BY" FWS Extended-Domain 2912 Extended-Domain = Domain / 2913 ( Domain FWS "(" TCP-info ")" ) / 2914 ( address-literal FWS "(" TCP-info ")" ) 2916 TCP-info = address-literal / ( Domain FWS address-literal ) 2917 ; Information derived by server from TCP connection 2918 ; not client EHLO. 2920 Opt-info = [Via] [With] [ID] [For] 2921 [Additional-Registered-Clauses] 2923 Via = CFWS "VIA" FWS Link 2925 With = CFWS "WITH" FWS Protocol 2927 ID = CFWS "ID" FWS ( Atom / msg-id ) 2928 ; msg-id is defined in RFC 5322 [11] 2930 For = CFWS "FOR" FWS ( Path / Mailbox ) 2932 Additional-Registered-Clauses = 1* (CFWS Atom FWS String) 2933 [[CREF23: [5321bis] 5321 errata #1683, 20090215, 2934 Roberto Javier Godoy, rjgodoy@fich.unl.edu.ar]] 2935 ; Additional standard clauses may be added in this 2936 ; location by future standards and registration with 2937 ; IANA. SMTP servers SHOULD NOT use unregistered 2938 ; names. See Section 8. 2940 Link = "TCP" / Addtl-Link 2942 Addtl-Link = Atom 2943 ; Additional standard names for links are 2944 ; registered with the Internet Assigned Numbers 2945 ; Authority (IANA). "Via" is primarily of value 2946 ; with non-Internet transports. SMTP servers 2947 ; SHOULD NOT use unregistered names. 2949 Protocol = "ESMTP" / "SMTP" / Attdl-Protocol 2951 Addtl-Protocol = Atom 2952 ; Additional standard names for protocols are 2953 ; registered with the Internet Assigned Numbers 2954 ; Authority (IANA) in the "mail parameters" 2955 ; registry [9]. SMTP servers SHOULD NOT 2956 ; use unregistered names. 2958 4.5. Additional Implementation Issues 2960 4.5.1. Minimum Implementation 2962 In order to make SMTP workable, the following minimum implementation 2963 MUST be provided by all receivers. The following commands MUST be 2964 supported to conform to this specification: 2966 EHLO 2967 HELO 2968 MAIL 2969 RCPT 2970 DATA 2971 RSET 2972 NOOP 2973 QUIT 2974 VRFY 2976 Any system that includes an SMTP server supporting mail relaying or 2977 delivery MUST support the reserved mailbox "postmaster" as a case- 2978 insensitive local name. This postmaster address is not strictly 2979 necessary if the server always returns 554 on connection opening (as 2980 described in Section 3.1). The requirement to accept mail for 2981 postmaster implies that RCPT commands that specify a mailbox for 2982 postmaster at any of the domains for which the SMTP server provides 2983 mail service, as well as the special case of "RCPT TO:" 2984 (with no domain specification), MUST be supported. 2986 SMTP systems are expected to make every reasonable effort to accept 2987 mail directed to Postmaster from any other system on the Internet. 2988 In extreme cases -- such as to contain a denial of service attack or 2989 other breach of security -- an SMTP server may block mail directed to 2990 Postmaster. However, such arrangements SHOULD be narrowly tailored 2991 so as to avoid blocking messages that are not part of such attacks. 2993 4.5.2. Transparency 2995 Without some provision for data transparency, the character sequence 2996 "." ends the mail text and cannot be sent by the user. 2997 In general, users are not aware of such "forbidden" sequences. To 2998 allow all user composed text to be transmitted transparently, the 2999 following procedures are used: 3001 o Before sending a line of mail text, the SMTP client checks the 3002 first character of the line. If it is a period, one additional 3003 period is inserted at the beginning of the line. 3005 o When a line of mail text is received by the SMTP server, it checks 3006 the line. If the line is composed of a single period, it is 3007 treated as the end of mail indicator. If the first character is a 3008 period and there are other characters on the line, the first 3009 character is deleted. 3011 The mail data may contain any of the 128 ASCII characters. All 3012 characters are to be delivered to the recipient's mailbox, including 3013 spaces, vertical and horizontal tabs, and other control characters. 3014 If the transmission channel provides an 8-bit byte (octet) data 3015 stream, the 7-bit ASCII codes are transmitted, right justified, in 3016 the octets, with the high-order bits cleared to zero. See 3017 Section 3.6 for special treatment of these conditions in SMTP systems 3018 serving a relay function. 3020 In some systems, it may be necessary to transform the data as it is 3021 received and stored. This may be necessary for hosts that use a 3022 different character set than ASCII as their local character set, that 3023 store data in records rather than strings, or which use special 3024 character sequences as delimiters inside mailboxes. If such 3025 transformations are necessary, they MUST be reversible, especially if 3026 they are applied to mail being relayed. 3028 4.5.3. Sizes and Timeouts 3030 4.5.3.1. Size Limits and Minimums 3032 There are several objects that have required minimum/maximum sizes. 3033 Every implementation MUST be able to receive objects of at least 3034 these sizes. Objects larger than these sizes SHOULD be avoided when 3035 possible. However, some Internet mail constructs such as encoded 3036 X.400 addresses (RFC 2156 [31]) will often require larger objects. 3037 Clients MAY attempt to transmit these, but MUST be prepared for a 3038 server to reject them if they cannot be handled by it. To the 3039 maximum extent possible, implementation techniques that impose no 3040 limits on the length of these objects should be used. 3042 Extensions to SMTP may involve the use of characters that occupy more 3043 than a single octet each. This section therefore specifies lengths 3044 in octets where absolute lengths, rather than character counts, are 3045 intended. 3047 [[CREF24: [5321bis] [[Note in Draft: Klensin 20191126: Given the 3048 controversy on the SMTP mailing list between 20191123 and now about 3049 maximum lengths, is the above adequate or is further tuning of the 3050 limit text below needed? ]]]] 3052 4.5.3.1.1. Local-part 3054 The maximum total length of a user name or other local-part is 64 3055 octets. 3057 4.5.3.1.2. Domain 3059 The maximum total length of a domain name or number is 255 octets. 3061 4.5.3.1.3. Path 3063 The maximum total length of a reverse-path or forward-path is 256 3064 octets (including the punctuation and element separators). 3066 4.5.3.1.4. Command Line 3068 The maximum total length of a command line including the command word 3069 and the is 512 octets. SMTP extensions may be used to 3070 increase this limit. 3072 4.5.3.1.5. Reply Line 3074 The maximum total length of a reply line including the reply code and 3075 the is 512 octets. More information may be conveyed through 3076 multiple-line replies. 3078 4.5.3.1.6. Text Line 3080 The maximum total length of a text line including the is 1000 3081 octets (not counting the leading dot duplicated for transparency). 3082 This number may be increased by the use of SMTP Service Extensions. 3084 4.5.3.1.7. Message Content 3086 The maximum total length of a message content (including any message 3087 header section as well as the message body) MUST BE at least 64K 3088 octets. Since the introduction of Internet Standards for multimedia 3089 mail (RFC 2045 [29]), message lengths on the Internet have grown 3090 dramatically, and message size restrictions should be avoided if at 3091 all possible. SMTP server systems that must impose restrictions 3092 SHOULD implement the "SIZE" service extension of RFC 1870 [4], and 3093 SMTP client systems that will send large messages SHOULD utilize it 3094 when possible. 3096 4.5.3.1.8. Recipient Buffer 3098 The minimum total number of recipients that MUST be buffered is 100 3099 recipients. Rejection of messages (for excessive recipients) with 3100 fewer than 100 RCPT commands is a violation of this specification. 3101 The general principle that relaying SMTP server MUST NOT, and 3102 delivery SMTP servers SHOULD NOT, perform validation tests on message 3103 header fields suggests that messages SHOULD NOT be rejected based on 3104 the total number of recipients shown in header fields. A server that 3105 imposes a limit on the number of recipients MUST behave in an orderly 3106 fashion, such as rejecting additional addresses over its limit rather 3107 than silently discarding addresses previously accepted. A client 3108 that needs to deliver a message containing over 100 RCPT commands 3109 SHOULD be prepared to transmit in 100-recipient "chunks" if the 3110 server declines to accept more than 100 recipients in a single 3111 message. 3113 4.5.3.1.9. Treatment When Limits Exceeded 3115 Errors due to exceeding these limits may be reported by using the 3116 reply codes. Some examples of reply codes are: 3118 500 Line too long. 3120 or 3122 501 Path too long 3124 or 3126 452 Too many recipients (see below) 3128 or 3130 552 Too much mail data. 3132 4.5.3.1.10. Too Many Recipients Code 3134 RFC 821 [8] incorrectly listed the error where an SMTP server 3135 exhausts its implementation limit on the number of RCPT commands 3136 ("too many recipients") as having reply code 552. The correct reply 3137 code for this condition is 452. Clients SHOULD treat a 552 code in 3138 this case as a temporary, rather than permanent, failure so the logic 3139 below works. 3141 When a conforming SMTP server encounters this condition, it has at 3142 least 100 successful RCPT commands in its recipient buffer. If the 3143 server is able to accept the message, then at least these 100 3144 addresses will be removed from the SMTP client's queue. When the 3145 client attempts retransmission of those addresses that received 452 3146 responses, at least 100 of these will be able to fit in the SMTP 3147 server's recipient buffer. Each retransmission attempt that is able 3148 to deliver anything will be able to dispose of at least 100 of these 3149 recipients. 3151 If an SMTP server has an implementation limit on the number of RCPT 3152 commands and this limit is exhausted, it MUST use a response code of 3153 452 (but the client SHOULD also be prepared for a 552, as noted 3154 above). If the server has a configured site-policy limitation on the 3155 number of RCPT commands, it MAY instead use a 5yz response code. In 3156 particular, if the intent is to prohibit messages with more than a 3157 site-specified number of recipients, rather than merely limit the 3158 number of recipients in a given mail transaction, it would be 3159 reasonable to return a 503 response to any DATA command received 3160 subsequent to the 452 (or 552) code or to simply return the 503 after 3161 DATA without returning any previous negative response. 3163 4.5.3.2. Timeouts 3165 An SMTP client MUST provide a timeout mechanism. It MUST use per- 3166 command timeouts rather than somehow trying to time the entire mail 3167 transaction. Timeouts SHOULD be easily reconfigurable, preferably 3168 without recompiling the SMTP code. To implement this, a timer is set 3169 for each SMTP command and for each buffer of the data transfer. The 3170 latter means that the overall timeout is inherently proportional to 3171 the size of the message. 3173 Based on extensive experience with busy mail-relay hosts, the minimum 3174 per-command timeout values SHOULD be as follows: 3176 4.5.3.2.1. Initial 220 Message: 5 Minutes 3178 An SMTP client process needs to distinguish between a failed TCP 3179 connection and a delay in receiving the initial 220 greeting message. 3180 Many SMTP servers accept a TCP connection but delay delivery of the 3181 220 message until their system load permits more mail to be 3182 processed. 3184 4.5.3.2.2. MAIL Command: 5 Minutes 3186 4.5.3.2.3. RCPT Command: 5 Minutes 3188 A longer timeout is required if processing of mailing lists and 3189 aliases is not deferred until after the message was accepted. 3191 4.5.3.2.4. DATA Initiation: 2 Minutes 3193 This is while awaiting the "354 Start Input" reply to a DATA command. 3195 4.5.3.2.5. Data Block: 3 Minutes 3197 This is while awaiting the completion of each TCP SEND call 3198 transmitting a chunk of data. 3200 4.5.3.2.6. DATA Termination: 10 Minutes. 3202 This is while awaiting the "250 OK" reply. When the receiver gets 3203 the final period terminating the message data, it typically performs 3204 processing to deliver the message to a user mailbox. A spurious 3205 timeout at this point would be very wasteful and would typically 3206 result in delivery of multiple copies of the message, since it has 3207 been successfully sent and the server has accepted responsibility for 3208 delivery. See Section 6.1 for additional discussion. 3210 4.5.3.2.7. Server Timeout: 5 Minutes. 3212 An SMTP server SHOULD have a timeout of at least 5 minutes while it 3213 is awaiting the next command from the sender. 3215 4.5.4. Retry Strategies 3217 The common structure of a host SMTP implementation includes user 3218 mailboxes, one or more areas for queuing messages in transit, and one 3219 or more daemon processes for sending and receiving mail. The exact 3220 structure will vary depending on the needs of the users on the host 3221 and the number and size of mailing lists supported by the host. We 3222 describe several optimizations that have proved helpful, particularly 3223 for mailers supporting high traffic levels. 3225 Any queuing strategy MUST include timeouts on all activities on a 3226 per-command basis. A queuing strategy MUST NOT send error messages 3227 in response to error messages under any circumstances. 3229 4.5.4.1. Sending Strategy 3231 The general model for an SMTP client is one or more processes that 3232 periodically attempt to transmit outgoing mail. In a typical system, 3233 the program that composes a message has some method for requesting 3234 immediate attention for a new piece of outgoing mail, while mail that 3235 cannot be transmitted immediately MUST be queued and periodically 3236 retried by the sender. A mail queue entry will include not only the 3237 message itself but also the envelope information. 3239 The sender MUST delay retrying a particular destination after one 3240 attempt has failed. In general, the retry interval SHOULD be at 3241 least 30 minutes; however, more sophisticated and variable strategies 3242 will be beneficial when the SMTP client can determine the reason for 3243 non-delivery. 3245 Retries continue until the message is transmitted or the sender gives 3246 up; the give-up time generally needs to be at least 4-5 days. It MAY 3247 be appropriate to set a shorter maximum number of retries for non- 3248 delivery notifications and equivalent error messages than for 3249 standard messages. The parameters to the retry algorithm MUST be 3250 configurable. 3252 A client SHOULD keep a list of hosts it cannot reach and 3253 corresponding connection timeouts, rather than just retrying queued 3254 mail items. 3256 Experience suggests that failures are typically transient (the target 3257 system or its connection has crashed), favoring a policy of two 3258 connection attempts in the first hour the message is in the queue, 3259 and then backing off to one every two or three hours. 3261 The SMTP client can shorten the queuing delay in cooperation with the 3262 SMTP server. For example, if mail is received from a particular 3263 address, it is likely that mail queued for that host can now be sent. 3264 Application of this principle may, in many cases, eliminate the 3265 requirement for an explicit "send queues now" function such as ETRN, 3266 RFC 1985 [28]. 3268 The strategy may be further modified as a result of multiple 3269 addresses per host (see below) to optimize delivery time versus 3270 resource usage. 3272 An SMTP client may have a large queue of messages for each 3273 unavailable destination host. If all of these messages were retried 3274 in every retry cycle, there would be excessive Internet overhead and 3275 the sending system would be blocked for a long period. Note that an 3276 SMTP client can generally determine that a delivery attempt has 3277 failed only after a timeout of several minutes, and even a one-minute 3278 timeout per connection will result in a very large delay if retries 3279 are repeated for dozens, or even hundreds, of queued messages to the 3280 same host. 3282 At the same time, SMTP clients SHOULD use great care in caching 3283 negative responses from servers. In an extreme case, if EHLO is 3284 issued multiple times during the same SMTP connection, different 3285 answers may be returned by the server. More significantly, 5yz 3286 responses to the MAIL command MUST NOT be cached. 3288 When a mail message is to be delivered to multiple recipients, and 3289 the SMTP server to which a copy of the message is to be sent is the 3290 same for multiple recipients, then only one copy of the message 3291 SHOULD be transmitted. That is, the SMTP client SHOULD use the 3292 command sequence: MAIL, RCPT, RCPT, ..., RCPT, DATA instead of the 3293 sequence: MAIL, RCPT, DATA, ..., MAIL, RCPT, DATA. However, if there 3294 are very many addresses, a limit on the number of RCPT commands per 3295 MAIL command MAY be imposed. This efficiency feature SHOULD be 3296 implemented. 3298 Similarly, to achieve timely delivery, the SMTP client MAY support 3299 multiple concurrent outgoing mail transactions. However, some limit 3300 may be appropriate to protect the host from devoting all its 3301 resources to mail. 3303 4.5.4.2. Receiving Strategy 3305 The SMTP server SHOULD attempt to keep a pending listen on the SMTP 3306 port (specified by IANA as port 25) at all times. This requires the 3307 support of multiple incoming TCP connections for SMTP. Some limit 3308 MAY be imposed, but servers that cannot handle more than one SMTP 3309 transaction at a time are not in conformance with the intent of this 3310 specification. 3312 As discussed above, when the SMTP server receives mail from a 3313 particular host address, it could activate its own SMTP queuing 3314 mechanisms to retry any mail pending for that host address. 3316 4.5.5. Messages with a Null Reverse-Path 3318 There are several types of notification messages that are required by 3319 existing and proposed Standards to be sent with a null reverse-path, 3320 namely non-delivery notifications as discussed in Section 3.7, other 3321 kinds of Delivery Status Notifications (DSNs, RFC 3461 [12]), and 3322 Message Disposition Notifications (MDNs, RFC 3798 [40]). All of 3323 these kinds of messages are notifications about a previous message, 3324 and they are sent to the reverse-path of the previous mail message. 3326 (If the delivery of such a notification message fails, that usually 3327 indicates a problem with the mail system of the host to which the 3328 notification message is addressed. For this reason, at some hosts 3329 the MTA is set up to forward such failed notification messages to 3330 someone who is able to fix problems with the mail system, e.g., via 3331 the postmaster alias.) 3333 All other types of messages (i.e., any message which is not required 3334 by a Standards-Track RFC to have a null reverse-path) SHOULD be sent 3335 with a valid, non-null reverse-path. 3337 Implementers of automated email processors should be careful to make 3338 sure that the various kinds of messages with a null reverse-path are 3339 handled correctly. In particular, such systems SHOULD NOT reply to 3340 messages with a null reverse-path, and they SHOULD NOT add a non-null 3341 reverse-path, or change a null reverse-path to a non-null one, to 3342 such messages when forwarding. 3344 5. Address Resolution and Mail Handling 3346 5.1. Locating the Target Host 3348 Once an SMTP client lexically identifies a domain to which mail will 3349 be delivered for processing (as described in Sections 2.3.5 and 3.6), 3350 a DNS lookup MUST be performed to resolve the domain name (RFC 1035 3351 [7]). The names are expected to be fully-qualified domain names 3352 (FQDNs): mechanisms for inferring FQDNs from partial names or local 3353 aliases are outside of this specification. Due to a history of 3354 problems, SMTP servers used for initial submission of messages SHOULD 3355 NOT make such inferences (Message Submission Servers [43] have 3356 somewhat more flexibility) and intermediate (relay) SMTP servers MUST 3357 NOT make them. 3359 The lookup first attempts to locate an MX record associated with the 3360 name. If a CNAME record is found, the resulting name is processed as 3361 if it were the initial name. If a non-existent domain error is 3362 returned, this situation MUST be reported as an error. If a 3363 temporary error is returned, the message MUST be queued and retried 3364 later (see Section 4.5.4.1). If an empty list of MXs is returned, 3365 the address is treated as if it was associated with an implicit MX 3366 RR, with a preference of 0, pointing to that host. If MX records are 3367 present, but none of them are usable, or the implicit MX is unusable, 3368 this situation MUST be reported as an error. 3370 If one or more MX RRs are found for a given name, SMTP systems MUST 3371 NOT utilize any address RRs associated with that name unless they are 3372 located using the MX RRs; the "implicit MX" rule above applies only 3373 if there are no MX records present. If MX records are present, but 3374 none of them are usable, this situation MUST be reported as an error. 3376 When a domain name associated with an MX RR is looked up and the 3377 associated data field obtained, the data field of that response MUST 3378 contain a domain name that conforms to the specifications of 3379 Section 2.3.5. 3380 [[5321bis Editor's Note: Depending on how the "null MX" discussion 3381 unfolds, some additional text may be in order here (20140718)]] 3382 That domain name, when queried, MUST return at least one address 3383 record (e.g., A or AAAA RR) that gives the IP address of the SMTP 3384 server to which the message should be directed. Any other response, 3385 specifically including a value that will return a CNAME record when 3386 queried, lies outside the scope of this Standard. The prohibition on 3387 labels in the data that resolve to CNAMEs is discussed in more detail 3388 in RFC 2181, Section 10.3 [32]. 3390 When the lookup succeeds, the mapping can result in a list of 3391 alternative delivery addresses rather than a single address, because 3392 of multiple MX records, multihoming, or both. To provide reliable 3393 mail transmission, the SMTP client MUST be able to try (and retry) 3394 each of the relevant addresses in this list in order, until a 3395 delivery attempt succeeds. However, there MAY also be a configurable 3396 limit on the number of alternate addresses that can be tried. In any 3397 case, the SMTP client SHOULD try at least two addresses. 3399 Two types of information are used to rank the host addresses: 3400 multiple MX records, and multihomed hosts. 3402 MX records contain a preference indication that MUST be used in 3403 sorting if more than one such record appears (see below). Lower 3404 numbers are more preferred than higher ones. If there are multiple 3405 destinations with the same preference and there is no clear reason to 3406 favor one (e.g., by recognition of an easily reached address), then 3407 the sender-SMTP MUST randomize them to spread the load across 3408 multiple mail exchangers for a specific organization. 3410 The destination host (perhaps taken from the preferred MX record) may 3411 be multihomed, in which case the domain name resolver will return a 3412 list of alternative IP addresses. It is the responsibility of the 3413 domain name resolver interface to have ordered this list by 3414 decreasing preference if necessary, and the SMTP sender MUST try them 3415 in the order presented. 3417 Although the capability to try multiple alternative addresses is 3418 required, specific installations may want to limit or disable the use 3419 of alternative addresses. The question of whether a sender should 3420 attempt retries using the different addresses of a multihomed host 3421 has been controversial. The main argument for using the multiple 3422 addresses is that it maximizes the probability of timely delivery, 3423 and indeed sometimes the probability of any delivery; the counter- 3424 argument is that it may result in unnecessary resource use. Note 3425 that resource use is also strongly determined by the sending strategy 3426 discussed in Section 4.5.4.1. 3428 If an SMTP server receives a message with a destination for which it 3429 is a designated Mail eXchanger, it MAY relay the message (potentially 3430 after having rewritten the MAIL FROM and/or RCPT TO addresses), make 3431 final delivery of the message, or hand it off using some mechanism 3432 outside the SMTP-provided transport environment. Of course, neither 3433 of the latter require that the list of MX records be examined 3434 further. 3436 If it determines that it should relay the message without rewriting 3437 the address, it MUST sort the MX records to determine candidates for 3438 delivery. The records are first ordered by preference, with the 3439 lowest-numbered records being most preferred. The relay host MUST 3440 then inspect the list for any of the names or addresses by which it 3441 might be known in mail transactions. If a matching record is found, 3442 all records at that preference level and higher-numbered ones MUST be 3443 discarded from consideration. If there are no records left at that 3444 point, it is an error condition, and the message MUST be returned as 3445 undeliverable. If records do remain, they SHOULD be tried, best 3446 preference first, as described above. 3448 5.2. IPv6 and MX Records 3450 In the contemporary Internet, SMTP clients and servers may be hosted 3451 on IPv4 systems, IPv6 systems, or dual-stack systems that are 3452 compatible with either version of the Internet Protocol. The host 3453 domains to which MX records point may, consequently, contain "A RR"s 3454 (IPv4), "AAAA RR"s (IPv6), or any combination of them. While RFC 3455 3974 [14] discusses some operational experience in mixed 3456 environments, it was not comprehensive enough to justify 3457 standardization, and some of its recommendations appear to be 3458 inconsistent with this specification. The appropriate actions to be 3459 taken either will depend on local circumstances, such as performance 3460 of the relevant networks and any conversions that might be necessary, 3461 or will be obvious (e.g., an IPv6-only client need not attempt to 3462 look up A RRs or attempt to reach IPv4-only servers). Designers of 3463 SMTP implementations that might run in IPv6 or dual-stack 3464 environments should study the procedures above, especially the 3465 comments about multihomed hosts, and, preferably, provide mechanisms 3466 to facilitate operational tuning and mail interoperability between 3467 IPv4 and IPv6 systems while considering local circumstances. 3469 6. Problem Detection and Handling 3471 6.1. Reliable Delivery and Replies by Email 3473 When the receiver-SMTP accepts a piece of mail (by sending a "250 OK" 3474 message in response to DATA), it is accepting responsibility for 3475 delivering or relaying the message. It must take this responsibility 3476 seriously. It MUST NOT lose the message for frivolous reasons, such 3477 as because the host later crashes or because of a predictable 3478 resource shortage. Some reasons that are not considered frivolous 3479 are discussed in the next subsection and in Section 7.8. 3481 If there is a delivery failure after acceptance of a message, the 3482 receiver-SMTP MUST formulate and mail a notification message. This 3483 notification MUST be sent using a null ("<>") reverse-path in the 3484 envelope. The recipient of this notification MUST be the address 3485 from the envelope return path (or the Return-Path: line). However, 3486 if this address is null ("<>"), the receiver-SMTP MUST NOT send a 3487 notification. Obviously, nothing in this section can or should 3488 prohibit local decisions (i.e., as part of the same system 3489 environment as the receiver-SMTP) to log or otherwise transmit 3490 information about null address events locally if that is desired. If 3491 the address is an explicit source route, it MUST be stripped down to 3492 its final hop. 3494 For example, suppose that an error notification must be sent for a 3495 message that arrived with: 3497 MAIL FROM:<@a,@b:user@d> 3499 The notification message MUST be sent using: 3501 RCPT TO: 3503 Some delivery failures after the message is accepted by SMTP will be 3504 unavoidable. For example, it may be impossible for the receiving 3505 SMTP server to validate all the delivery addresses in RCPT command(s) 3506 due to a "soft" domain system error, because the target is a mailing 3507 list (see earlier discussion of RCPT), or because the server is 3508 acting as a relay and has no immediate access to the delivering 3509 system. 3511 To avoid receiving duplicate messages as the result of timeouts, a 3512 receiver-SMTP MUST seek to minimize the time required to respond to 3513 the final . end of data indicator. See RFC 1047 [20] for 3514 a discussion of this problem. 3516 6.2. Unwanted, Unsolicited, and "Attack" Messages 3518 Utility and predictability of the Internet mail system requires that 3519 messages that can be delivered should be delivered, regardless of any 3520 syntax or other faults associated with those messages and regardless 3521 of their content. If they cannot be delivered, and cannot be 3522 rejected by the SMTP server during the SMTP transaction, they should 3523 be "bounced" (returned with non-delivery notification messages) as 3524 described above. In today's world, in which many SMTP server 3525 operators have discovered that the quantity of undesirable bulk email 3526 vastly exceeds the quantity of desired mail and in which accepting a 3527 message may trigger additional undesirable traffic by providing 3528 verification of the address, those principles may not be practical. 3530 As discussed in Section 7.8 and Section 7.9 below, dropping mail 3531 without notification of the sender is permitted in practice. 3532 However, it is extremely dangerous and violates a long tradition and 3533 community expectations that mail is either delivered or returned. If 3534 silent message-dropping is misused, it could easily undermine 3535 confidence in the reliability of the Internet's mail systems. So 3536 silent dropping of messages should be considered only in those cases 3537 where there is very high confidence that the messages are seriously 3538 fraudulent or otherwise inappropriate. 3540 To stretch the principle of delivery if possible even further, it may 3541 be a rational policy to not deliver mail that has an invalid return 3542 address, although the history of the network is that users are 3543 typically better served by delivering any message that can be 3544 delivered. Reliably determining that a return address is invalid can 3545 be a difficult and time-consuming process, especially if the putative 3546 sending system is not directly accessible or does not fully and 3547 accurately support VRFY and, even if a "drop messages with invalid 3548 return addresses" policy is adopted, it SHOULD be applied only when 3549 there is near-certainty that the return addresses are, in fact, 3550 invalid. 3552 Conversely, if a message is rejected because it is found to contain 3553 hostile content (a decision that is outside the scope of an SMTP 3554 server as defined in this document), rejection ("bounce") messages 3555 SHOULD NOT be sent unless the receiving site is confident that those 3556 messages will be usefully delivered. The preference and default in 3557 these cases is to avoid sending non-delivery messages when the 3558 incoming message is determined to contain hostile content. 3560 6.3. Loop Detection 3562 Simple counting of the number of "Received:" header fields in a 3563 message has proven to be an effective, although rarely optimal, 3564 method of detecting loops in mail systems. SMTP servers using this 3565 technique SHOULD use a large rejection threshold, normally at least 3566 100 Received entries. Whatever mechanisms are used, servers MUST 3567 contain provisions for detecting and stopping trivial loops. 3569 6.4. Compensating for Irregularities 3571 Unfortunately, variations, creative interpretations, and outright 3572 violations of Internet mail protocols do occur; some would suggest 3573 that they occur quite frequently. The debate as to whether a well- 3574 behaved SMTP receiver or relay should reject a malformed message, 3575 attempt to pass it on unchanged, or attempt to repair it to increase 3576 the odds of successful delivery (or subsequent reply) began almost 3577 with the dawn of structured network mail and shows no signs of 3578 abating. Advocates of rejection claim that attempted repairs are 3579 rarely completely adequate and that rejection of bad messages is the 3580 only way to get the offending software repaired. Advocates of 3581 "repair" or "deliver no matter what" argue that users prefer that 3582 mail go through it if at all possible and that there are significant 3583 market pressures in that direction. In practice, these market 3584 pressures may be more important to particular vendors than strict 3585 conformance to the standards, regardless of the preference of the 3586 actual developers. 3588 The problems associated with ill-formed messages were exacerbated by 3589 the introduction of the split-UA mail reading protocols (Post Office 3590 Protocol (POP) version 2 [17], Post Office Protocol (POP) version 3 3591 [27], IMAP version 2 [22], and PCMAIL [21]). These protocols 3592 encouraged the use of SMTP as a posting (message submission) 3593 protocol, and SMTP servers as relay systems for these client hosts 3594 (which are often only intermittently connected to the Internet). 3595 Historically, many of those client machines lacked some of the 3596 mechanisms and information assumed by SMTP (and indeed, by the mail 3597 format protocol, RFC 822 [16]). Some could not keep adequate track 3598 of time; others had no concept of time zones; still others could not 3599 identify their own names or addresses; and, of course, none could 3600 satisfy the assumptions that underlay RFC 822's conception of 3601 authenticated addresses. 3603 In response to these weak SMTP clients, many SMTP systems now 3604 complete messages that are delivered to them in incomplete or 3605 incorrect form. This strategy is generally considered appropriate 3606 when the server can identify or authenticate the client, and there 3607 are prior agreements between them. By contrast, there is at best 3608 great concern about fixes applied by a relay or delivery SMTP server 3609 that has little or no knowledge of the user or client machine. Many 3610 of these issues are addressed by using a separate protocol, such as 3611 that defined in RFC 4409 [43], for message submission, rather than 3612 using originating SMTP servers for that purpose. 3614 The following changes to a message being processed MAY be applied 3615 when necessary by an originating SMTP server, or one used as the 3616 target of SMTP as an initial posting (message submission) protocol: 3618 o Addition of a message-id field when none appears 3620 o Addition of a date, time, or time zone when none appears 3622 o Correction of addresses to proper FQDN format 3624 The less information the server has about the client, the less likely 3625 these changes are to be correct and the more caution and conservatism 3626 should be applied when considering whether or not to perform fixes 3627 and how. These changes MUST NOT be applied by an SMTP server that 3628 provides an intermediate relay function. 3630 In all cases, properly operating clients supplying correct 3631 information are preferred to corrections by the SMTP server. In all 3632 cases, documentation SHOULD be provided in trace header fields and/or 3633 header field comments for actions performed by the servers. 3635 7. Security Considerations 3637 7.1. Mail Security and Spoofing 3639 SMTP mail is inherently insecure in that it is feasible for even 3640 fairly casual users to negotiate directly with receiving and relaying 3641 SMTP servers and create messages that will trick a naive recipient 3642 into believing that they came from somewhere else. Constructing such 3643 a message so that the "spoofed" behavior cannot be detected by an 3644 expert is somewhat more difficult, but not sufficiently so as to be a 3645 deterrent to someone who is determined and knowledgeable. 3646 Consequently, as knowledge of Internet mail increases, so does the 3647 knowledge that SMTP mail inherently cannot be authenticated, or 3648 integrity checks provided, at the transport level. Real mail 3649 security lies only in end-to-end methods involving the message 3650 bodies, such as those that use digital signatures (see RFC 1847 [25] 3651 and, e.g., Pretty Good Privacy (PGP) in RFC 4880 [15] or Secure/ 3652 Multipurpose Internet Mail Extensions (S/MIME) in RFC 3851 [41]). 3654 Various protocol extensions and configuration options that provide 3655 authentication at the transport level (e.g., from an SMTP client to 3656 an SMTP server) improve somewhat on the traditional situation 3657 described above. However, in general, they only authenticate one 3658 server to another rather than a chain of relays and servers, much 3659 less authenticating users or user machines. Consequently, unless 3660 they are accompanied by careful handoffs of responsibility in a 3661 carefully designed trust environment, they remain inherently weaker 3662 than end-to-end mechanisms that use digitally signed messages rather 3663 than depending on the integrity of the transport system. 3665 Efforts to make it more difficult for users to set envelope return 3666 path and header "From" fields to point to valid addresses other than 3667 their own are largely misguided: they frustrate legitimate 3668 applications in which mail is sent by one user on behalf of another, 3669 in which error (or normal) replies should be directed to a special 3670 address, or in which a single message is sent to multiple recipients 3671 on different hosts. (Systems that provide convenient ways for users 3672 to alter these header fields on a per-message basis should attempt to 3673 establish a primary and permanent mailbox address for the user so 3674 that Sender header fields within the message data can be generated 3675 sensibly.) 3677 This specification does not further address the authentication issues 3678 associated with SMTP other than to advocate that useful functionality 3679 not be disabled in the hope of providing some small margin of 3680 protection against a user who is trying to fake mail. 3682 7.2. "Blind" Copies 3684 Addresses that do not appear in the message header section may appear 3685 in the RCPT commands to an SMTP server for a number of reasons. The 3686 two most common involve the use of a mailing address as a "list 3687 exploder" (a single address that resolves into multiple addresses) 3688 and the appearance of "blind copies". Especially when more than one 3689 RCPT command is present, and in order to avoid defeating some of the 3690 purpose of these mechanisms, SMTP clients and servers SHOULD NOT copy 3691 the full set of RCPT command arguments into the header section, 3692 either as part of trace header fields or as informational or private- 3693 extension header fields. [[CREF25: [rfc5321bis] [[Note in draft - 3694 Suggestion from 20070124 that got lost: delete "especially" and "the 3695 full set of" -- copying the first one can be as harmful as copying 3696 all of them, at least without verifying that the addresses do appear 3697 in the headers.]] Arnt Gulbrandsen, arnt@oryx.com, 2007.01.24 3698 1121+0100]] Since this rule is often violated in practice, and cannot 3699 be enforced, sending SMTP systems that are aware of "bcc" use MAY 3700 find it helpful to send each blind copy as a separate message 3701 transaction containing only a single RCPT command. 3703 There is no inherent relationship between either "reverse" (from 3704 MAIL, SAML, etc., commands) or "forward" (RCPT) addresses in the SMTP 3705 transaction ("envelope") and the addresses in the header section. 3706 Receiving systems SHOULD NOT attempt to deduce such relationships and 3707 use them to alter the header section of the message for delivery. 3708 The popular "Apparently-to" header field is a violation of this 3709 principle as well as a common source of unintended information 3710 disclosure and SHOULD NOT be used. 3712 7.3. VRFY, EXPN, and Security 3714 As discussed in Section 3.5, individual sites may want to disable 3715 either or both of VRFY or EXPN for security reasons (see below). As 3716 a corollary to the above, implementations that permit this MUST NOT 3717 appear to have verified addresses that are not, in fact, verified. 3718 If a site disables these commands for security reasons, the SMTP 3719 server MUST return a 252 response, rather than a code that could be 3720 confused with successful or unsuccessful verification. 3722 Returning a 250 reply code with the address listed in the VRFY 3723 command after having checked it only for syntax violates this rule. 3724 Of course, an implementation that "supports" VRFY by always returning 3725 550 whether or not the address is valid is equally not in 3726 conformance. 3728 On the public Internet, the contents of mailing lists have become 3729 popular as an address information source for so-called "spammers." 3730 The use of EXPN to "harvest" addresses has increased as list 3731 administrators have installed protections against inappropriate uses 3732 of the lists themselves. However, VRFY and EXPN are still useful for 3733 authenticated users and within an administrative domain. For 3734 example, VRFY and EXPN are useful for performing internal audits of 3735 how email gets routed to check and to make sure no one is 3736 automatically forwarding sensitive mail outside the organization. 3737 Sites implementing SMTP authentication may choose to make VRFY and 3738 EXPN available only to authenticated requestors. Implementations 3739 SHOULD still provide support for EXPN, but sites SHOULD carefully 3740 evaluate the tradeoffs. 3742 Whether disabling VRFY provides any real marginal security depends on 3743 a series of other conditions. In many cases, RCPT commands can be 3744 used to obtain the same information about address validity. On the 3745 other hand, especially in situations where determination of address 3746 validity for RCPT commands is deferred until after the DATA command 3747 is received, RCPT may return no information at all, while VRFY is 3748 expected to make a serious attempt to determine validity before 3749 generating a response code (see discussion above). 3751 7.4. Mail Rerouting Based on the 251 and 551 Response Codes 3753 Before a client uses the 251 or 551 reply codes from a RCPT command 3754 to automatically update its future behavior (e.g., updating the 3755 user's address book), it should be certain of the server's 3756 authenticity. If it does not, it may be subject to a man in the 3757 middle attack. 3759 7.5. Information Disclosure in Announcements 3761 There has been an ongoing debate about the tradeoffs between the 3762 debugging advantages of announcing server type and version (and, 3763 sometimes, even server domain name) in the greeting response or in 3764 response to the HELP command and the disadvantages of exposing 3765 information that might be useful in a potential hostile attack. The 3766 utility of the debugging information is beyond doubt. Those who 3767 argue for making it available point out that it is far better to 3768 actually secure an SMTP server rather than hope that trying to 3769 conceal known vulnerabilities by hiding the server's precise identity 3770 will provide more protection. Sites are encouraged to evaluate the 3771 tradeoff with that issue in mind; implementations SHOULD minimally 3772 provide for making type and version information available in some way 3773 to other network hosts. 3775 7.6. Information Disclosure in Trace Fields 3777 In some circumstances, such as when mail originates from within a LAN 3778 whose hosts are not directly on the public Internet, trace 3779 ("Received") header fields produced in conformance with this 3780 specification may disclose host names and similar information that 3781 would not normally be available. This ordinarily does not pose a 3782 problem, but sites with special concerns about name disclosure should 3783 be aware of it. Also, the optional FOR clause should be supplied 3784 with caution or not at all when multiple recipients are involved lest 3785 it inadvertently disclose the identities of "blind copy" recipients 3786 to others. 3788 7.7. Information Disclosure in Message Forwarding 3790 As discussed in Section 3.4, use of the 251 or 551 reply codes to 3791 identify the replacement address associated with a mailbox may 3792 inadvertently disclose sensitive information. Sites that are 3793 concerned about those issues should ensure that they select and 3794 configure servers appropriately. 3796 7.8. Resistance to Attacks 3798 In recent years, there has been an increase of attacks on SMTP 3799 servers, either in conjunction with attempts to discover addresses 3800 for sending unsolicited messages or simply to make the servers 3801 inaccessible to others (i.e., as an application-level denial of 3802 service attack). While the means of doing so are beyond the scope of 3803 this Standard, rational operational behavior requires that servers be 3804 permitted to detect such attacks and take action to defend 3805 themselves. For example, if a server determines that a large number 3806 of RCPT TO commands are being sent, most or all with invalid 3807 addresses, as part of such an attack, it would be reasonable for the 3808 server to close the connection after generating an appropriate number 3809 of 5yz (normally 550) replies. 3811 7.9. Scope of Operation of SMTP Servers 3813 It is a well-established principle that an SMTP server may refuse to 3814 accept mail for any operational or technical reason that makes sense 3815 to the site providing the server. However, cooperation among sites 3816 and installations makes the Internet possible. If sites take 3817 excessive advantage of the right to reject traffic, the ubiquity of 3818 email availability (one of the strengths of the Internet) will be 3819 threatened; considerable care should be taken and balance maintained 3820 if a site decides to be selective about the traffic it will accept 3821 and process. 3823 In recent years, use of the relay function through arbitrary sites 3824 has been used as part of hostile efforts to hide the actual origins 3825 of mail. Some sites have decided to limit the use of the relay 3826 function to known or identifiable sources, and implementations SHOULD 3827 provide the capability to perform this type of filtering. When mail 3828 is rejected for these or other policy reasons, a 550 code SHOULD be 3829 used in response to EHLO (or HELO), MAIL, or RCPT as appropriate. 3831 8. IANA Considerations 3833 IANA maintains three registries in support of this specification, all 3834 of which were created for RFC 2821 or earlier. This document expands 3835 the third one as specified below. The registry references listed are 3836 as of the time of publication; IANA does not guarantee the locations 3837 associated with the URLs. The registries are as follows: 3839 o The first, "Simple Mail Transfer Protocol (SMTP) Service 3840 Extensions" [49], consists of SMTP service extensions with the 3841 associated keywords, and, as needed, parameters and verbs. As 3842 specified in Section 2.2.2, no entry may be made in this registry 3843 that starts in an "X". Entries may be made only for service 3844 extensions (and associated keywords, parameters, or verbs) that 3845 are defined in Standards-Track or Experimental RFCs specifically 3846 approved by the IESG for this purpose. 3848 o The second registry, "Address Literal Tags" [50], consists of 3849 "tags" that identify forms of domain literals other than those for 3850 IPv4 addresses (specified in RFC 821 and in this document). The 3851 initial entry in that registry is for IPv6 addresses (specified in 3852 this document). Additional literal types require standardization 3853 before being used; none are anticipated at this time. 3855 o The third, "Mail Transmission Types" [49], established by RFC 821 3856 and renewed by this specification, is a registry of link and 3857 protocol identifiers to be used with the "via" and "with" 3858 subclauses of the time stamp ("Received:" header field) described 3859 in Section 4.4. Link and protocol identifiers in addition to 3860 those specified in this document may be registered only by 3861 standardization or by way of an RFC-documented, IESG-approved, 3862 Experimental protocol extension. This name space is for 3863 identification and not limited in size: the IESG is encouraged to 3864 approve on the basis of clear documentation and a distinct method 3865 rather than preferences about the properties of the method itself. 3867 An additional subsection has been added to the "VIA link types" 3868 and "WITH protocol types" subsections of this registry to contain 3869 registrations of "Additional-registered-clauses" as described 3870 above. The registry will contain clause names, a description, a 3871 summary of the syntax of the associated String, and a reference. 3872 As new clauses are defined, they may, in principle, specify 3873 creation of their own registries if the Strings consist of 3874 reserved terms or keywords rather than less restricted strings. 3875 As with link and protocol identifiers, additional clauses may be 3876 registered only by standardization or by way of an RFC-documented, 3877 IESG-approved, Experimental protocol extension. The additional 3878 clause name space is for identification and is not limited in 3879 size: the IESG is encouraged to approve on the basis of clear 3880 documentation, actual use or strong signs that the clause will be 3881 used, and a distinct requirement rather than preferences about the 3882 properties of the clause itself. 3884 In addition, if additional trace header fields (i.e., in addition to 3885 Return-path and Received) are ever created, those trace fields MUST 3886 be added to the IANA registry established by BCP 90 (RFC 3864) [10] 3887 for use with RFC 5322 [11]. 3889 9. Acknowledgments 3891 Many people contributed to the development of RFCs 2821 and 5321. 3892 Those documents should be consulted for those acknowledgments. 3894 Neither this document nor RFCs 2821 or 5321 would have been possible 3895 without the many contribution and insights of the late Jon Postel. 3896 Those contributions of course include the original specification of 3897 SMTP in RFC 821. A considerable quantity of text from RFC 821 still 3898 appears in this document as do several of Jon's original examples 3899 that have been updated only as needed to reflect other changes in the 3900 specification. 3902 The following filed errata against RFC 5321 that were not rejected at 3903 the time of submission: Jasen Betts, Adrien de Croy Guillaume Fortin- 3904 Debigare Roberto Javier Godoy, David Romerstein, Dominic Sayers, 3905 Rodrigo Speller, Alessandro Vesely, and Brett Watson. In addition, 3906 specific suggestions that led to corrections and improvements in this 3907 version were received from Ned Freed, Barry Leiba, Ivar Lumi, Pete 3908 Resnick, and others. 3910 [[CREF26: Errata and comments after 2019-12-01 have not yet been 3911 captured in this version of the draft. ]] 3913 10. References 3915 10.1. Normative References 3917 [1] Bradner, S., "Key words for use in RFCs to Indicate 3918 Requirement Levels", BCP 14, RFC 2119, 3919 DOI 10.17487/RFC2119, March 1997, 3920 . 3922 [2] American National Standards Institute (formerly United 3923 States of America Standards Institute), "USA Code for 3924 Information Interchange", ANSI X3.4-1968, 1968. 3926 ANSI X3.4-1968 has been replaced by newer versions with 3927 slight modifications, but the 1968 version remains 3928 definitive for the Internet. 3930 [3] Braden, R., Ed., "Requirements for Internet Hosts - 3931 Application and Support", STD 3, RFC 1123, 3932 DOI 10.17487/RFC1123, October 1989, 3933 . 3935 [4] Klensin, J., Freed, N., and K. Moore, "SMTP Service 3936 Extension for Message Size Declaration", STD 10, RFC 1870, 3937 DOI 10.17487/RFC1870, November 1995, 3938 . 3940 [5] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax 3941 Specifications: ABNF", STD 68, RFC 5234, 3942 DOI 10.17487/RFC5234, January 2008, 3943 . 3945 [6] Hinden, R. and S. Deering, "IP Version 6 Addressing 3946 Architecture", RFC 4291, DOI 10.17487/RFC4291, February 3947 2006, . 3949 [7] Mockapetris, P., "Domain names - implementation and 3950 specification", STD 13, RFC 1035, DOI 10.17487/RFC1035, 3951 November 1987, . 3953 [8] Postel, J., "Simple Mail Transfer Protocol", STD 10, 3954 RFC 821, DOI 10.17487/RFC0821, August 1982, 3955 . 3957 [9] Newman, C., "ESMTP and LMTP Transmission Types 3958 Registration", RFC 3848, DOI 10.17487/RFC3848, July 2004, 3959 . 3961 [10] Klyne, G., Nottingham, M., and J. Mogul, "Registration 3962 Procedures for Message Header Fields", BCP 90, RFC 3864, 3963 DOI 10.17487/RFC3864, September 2004, 3964 . 3966 [11] Resnick, P., "Internet Message Format", RFC 5322, 3967 September 2008. 3969 10.2. Informative References 3971 [12] Moore, K., "Simple Mail Transfer Protocol (SMTP) Service 3972 Extension for Delivery Status Notifications (DSNs)", 3973 RFC 3461, DOI 10.17487/RFC3461, January 2003, 3974 . 3976 [13] Moore, K. and G. Vaudreuil, "An Extensible Message Format 3977 for Delivery Status Notifications", RFC 3464, 3978 DOI 10.17487/RFC3464, January 2003, 3979 . 3981 [14] Nakamura, M. and J. Hagino, "SMTP Operational Experience 3982 in Mixed IPv4/v6 Environments", RFC 3974, 3983 DOI 10.17487/RFC3974, January 2005, 3984 . 3986 [15] Callas, J., Donnerhacke, L., Finney, H., Shaw, D., and R. 3987 Thayer, "OpenPGP Message Format", RFC 4880, 3988 DOI 10.17487/RFC4880, November 2007, 3989 . 3991 [16] Crocker, D., "STANDARD FOR THE FORMAT OF ARPA INTERNET 3992 TEXT MESSAGES", STD 11, RFC 822, DOI 10.17487/RFC0822, 3993 August 1982, . 3995 [17] Butler, M., Postel, J., Chase, D., Goldberger, J., and J. 3996 Reynolds, "Post Office Protocol: Version 2", RFC 937, 3997 DOI 10.17487/RFC0937, February 1985, 3998 . 4000 [18] Postel, J. and J. Reynolds, "File Transfer Protocol", 4001 STD 9, RFC 959, DOI 10.17487/RFC0959, October 1985, 4002 . 4004 [19] Partridge, C., "Mail routing and the domain system", 4005 STD 10, RFC 974, DOI 10.17487/RFC0974, January 1986, 4006 . 4008 [20] Partridge, C., "Duplicate messages and SMTP", RFC 1047, 4009 DOI 10.17487/RFC1047, February 1988, 4010 . 4012 [21] Lambert, M., "PCMAIL: A distributed mail system for 4013 personal computers", RFC 1056, DOI 10.17487/RFC1056, June 4014 1988, . 4016 [22] Crispin, M., "Interactive Mail Access Protocol: Version 4017 2", RFC 1176, DOI 10.17487/RFC1176, August 1990, 4018 . 4020 [23] Klensin, J., Freed, N., Rose, M., Stefferud, E., and D. 4021 Crocker, "SMTP Service Extension for 8bit-MIMEtransport", 4022 RFC 1652, DOI 10.17487/RFC1652, July 1994, 4023 . 4025 [24] Durand, A. and F. Dupont, "SMTP 521 Reply Code", RFC 1846, 4026 DOI 10.17487/RFC1846, September 1995, 4027 . 4029 [25] Galvin, J., Murphy, S., Crocker, S., and N. Freed, 4030 "Security Multiparts for MIME: Multipart/Signed and 4031 Multipart/Encrypted", RFC 1847, DOI 10.17487/RFC1847, 4032 October 1995, . 4034 [26] Klensin, J., Freed, N., Rose, M., Stefferud, E., and D. 4035 Crocker, "SMTP Service Extensions", STD 10, RFC 1869, 4036 DOI 10.17487/RFC1869, November 1995, 4037 . 4039 [27] Myers, J. and M. Rose, "Post Office Protocol - Version 3", 4040 STD 53, RFC 1939, DOI 10.17487/RFC1939, May 1996, 4041 . 4043 [28] De Winter, J., "SMTP Service Extension for Remote Message 4044 Queue Starting", RFC 1985, DOI 10.17487/RFC1985, August 4045 1996, . 4047 [29] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 4048 Extensions (MIME) Part One: Format of Internet Message 4049 Bodies", RFC 2045, DOI 10.17487/RFC2045, November 1996, 4050 . 4052 [30] Moore, K., "MIME (Multipurpose Internet Mail Extensions) 4053 Part Three: Message Header Extensions for Non-ASCII Text", 4054 RFC 2047, DOI 10.17487/RFC2047, November 1996, 4055 . 4057 [31] Kille, S., "MIXER (Mime Internet X.400 Enhanced Relay): 4058 Mapping between X.400 and RFC 822/MIME", RFC 2156, 4059 DOI 10.17487/RFC2156, January 1998, 4060 . 4062 [32] Elz, R. and R. Bush, "Clarifications to the DNS 4063 Specification", RFC 2181, DOI 10.17487/RFC2181, July 1997, 4064 . 4066 [33] Freed, N. and K. Moore, "MIME Parameter Value and Encoded 4067 Word Extensions: Character Sets, Languages, and 4068 Continuations", RFC 2231, DOI 10.17487/RFC2231, November 4069 1997, . 4071 [34] Klensin, J., Ed., "Simple Mail Transfer Protocol", 4072 RFC 2821, DOI 10.17487/RFC2821, April 2001, 4073 . 4075 [35] Freed, N., "SMTP Service Extension for Command 4076 Pipelining", STD 60, RFC 2920, DOI 10.17487/RFC2920, 4077 September 2000, . 4079 [36] Freed, N., "Behavior of and Requirements for Internet 4080 Firewalls", RFC 2979, DOI 10.17487/RFC2979, October 2000, 4081 . 4083 [37] Vaudreuil, G., "SMTP Service Extensions for Transmission 4084 of Large and Binary MIME Messages", RFC 3030, 4085 DOI 10.17487/RFC3030, December 2000, 4086 . 4088 [38] Vaudreuil, G., "Enhanced Mail System Status Codes", 4089 RFC 3463, DOI 10.17487/RFC3463, January 2003, 4090 . 4092 [39] Crispin, M., "INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4093 4rev1", RFC 3501, DOI 10.17487/RFC3501, March 2003, 4094 . 4096 [40] Hansen, T., Ed. and G. Vaudreuil, Ed., "Message 4097 Disposition Notification", RFC 3798, DOI 10.17487/RFC3798, 4098 May 2004, . 4100 [41] Ramsdell, B., Ed., "Secure/Multipurpose Internet Mail 4101 Extensions (S/MIME) Version 3.1 Message Specification", 4102 RFC 3851, DOI 10.17487/RFC3851, July 2004, 4103 . 4105 [42] Wong, M. and W. Schlitt, "Sender Policy Framework (SPF) 4106 for Authorizing Use of Domains in E-Mail, Version 1", 4107 RFC 4408, DOI 10.17487/RFC4408, April 2006, 4108 . 4110 [43] Gellens, R. and J. Klensin, "Message Submission for Mail", 4111 RFC 4409, DOI 10.17487/RFC4409, April 2006, 4112 . 4114 [44] Fenton, J., "Analysis of Threats Motivating DomainKeys 4115 Identified Mail (DKIM)", RFC 4686, DOI 10.17487/RFC4686, 4116 September 2006, . 4118 [45] Allman, E., Callas, J., Delany, M., Libbey, M., Fenton, 4119 J., and M. Thomas, "DomainKeys Identified Mail (DKIM) 4120 Signatures", RFC 4871, DOI 10.17487/RFC4871, May 2007, 4121 . 4123 [46] Hansen, T. and J. Klensin, "A Registry for SMTP Enhanced 4124 Mail System Status Codes", BCP 138, RFC 5248, 4125 DOI 10.17487/RFC5248, June 2008, 4126 . 4128 [47] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 4129 Resource Identifier (URI): Generic Syntax", STD 66, 4130 RFC 3986, DOI 10.17487/RFC3986, January 2005, 4131 . 4133 [48] Klensin, J., "SMTP 521 and 556 Reply Codes", RFC 7504, 4134 DOI 10.17487/RFC7504, June 2015, 4135 . 4137 [49] Internet Assigned Number Authority (IANA), "IANA Mail 4138 Parameters", 2007, 4139 . 4141 [50] Internet Assigned Number Authority (IANA), "Address 4142 Literal Tags", 2007, 4143 . 4145 [51] Levine, J. and M. Delany, "A "Null MX" No Service Resource 4146 Record for Domains that Accept No Mail", September 2014, 4147 . 4150 [52] RFC Editor, "RFC Errata - RFC 5321", 2019, 4151 . 4153 Captured 2019-11-19 4155 Appendix A. TCP Transport Service 4157 The TCP connection supports the transmission of 8-bit bytes. The 4158 SMTP data is 7-bit ASCII characters. Each character is transmitted 4159 as an 8-bit byte with the high-order bit cleared to zero. Service 4160 extensions may modify this rule to permit transmission of full 8-bit 4161 data bytes as part of the message body, or, if specifically designed 4162 to do so, in SMTP commands or responses. 4164 Appendix B. Generating SMTP Commands from RFC 822 Header Fields 4166 Some systems use an RFC 822 header section (only) in a mail 4167 submission protocol, or otherwise generate SMTP commands from RFC 822 4168 header fields when such a message is handed to an MTA from a UA. 4169 While the MTA-UA protocol is a private matter, not covered by any 4170 Internet Standard, there are problems with this approach. For 4171 example, there have been repeated problems with proper handling of 4172 "bcc" copies and redistribution lists when information that 4173 conceptually belongs to the mail envelope is not separated early in 4174 processing from header field information (and kept separate). 4176 It is recommended that the UA provide its initial ("submission 4177 client") MTA with an envelope separate from the message itself. 4178 However, if the envelope is not supplied, SMTP commands SHOULD be 4179 generated as follows: 4181 1. Each recipient address from a TO, CC, or BCC header field SHOULD 4182 be copied to a RCPT command (generating multiple message copies 4183 if that is required for queuing or delivery). This includes any 4184 addresses listed in a RFC 822 "group". Any BCC header fields 4185 SHOULD then be removed from the header section. Once this 4186 process is completed, the remaining header fields SHOULD be 4187 checked to verify that at least one TO, CC, or BCC header field 4188 remains. If none do, then a BCC header field with no additional 4189 information SHOULD be inserted as specified in [11]. 4191 2. The return address in the MAIL command SHOULD, if possible, be 4192 derived from the system's identity for the submitting (local) 4193 user, and the "From:" header field otherwise. If there is a 4194 system identity available, it SHOULD also be copied to the Sender 4195 header field if it is different from the address in the From 4196 header field. (Any Sender header field that was already there 4197 SHOULD be removed.) Systems may provide a way for submitters to 4198 override the envelope return address, but may want to restrict 4199 its use to privileged users. This will not prevent mail forgery, 4200 but may lessen its incidence; see Section 7.1. 4202 When an MTA is being used in this way, it bears responsibility for 4203 ensuring that the message being transmitted is valid. The mechanisms 4204 for checking that validity, and for handling (or returning) messages 4205 that are not valid at the time of arrival, are part of the MUA-MTA 4206 interface and not covered by this specification. 4208 A submission protocol based on Standard RFC 822 information alone 4209 MUST NOT be used to gateway a message from a foreign (non-SMTP) mail 4210 system into an SMTP environment. Additional information to construct 4211 an envelope must come from some source in the other environment, 4212 whether supplemental header fields or the foreign system's envelope. 4214 Attempts to gateway messages using only their header "To" and "Cc" 4215 fields have repeatedly caused mail loops and other behavior adverse 4216 to the proper functioning of the Internet mail environment. These 4217 problems have been especially common when the message originates from 4218 an Internet mailing list and is distributed into the foreign 4219 environment using envelope information. When these messages are then 4220 processed by a header-section-only remailer, loops back to the 4221 Internet environment (and the mailing list) are almost inevitable. 4223 Appendix C. Source Routes 4225 Historically, the was a reverse source routing list of 4226 hosts and a source mailbox. The first host in the was 4227 historically the host sending the MAIL command; today, source routes 4228 SHOULD NOT appear in the reverse-path. Similarly, the 4229 may be a source routing lists of hosts and a destination mailbox. 4230 However, in general, the SHOULD contain only a mailbox 4231 and domain name, relying on the domain name system to supply routing 4232 information if required. The use of source routes is deprecated (see 4233 Appendix F.2); while servers MUST be prepared to receive and handle 4234 them as discussed in Section 3.3 and Appendix F.2, clients SHOULD NOT 4235 transmit them and this section is included in the current 4236 specification only to provide context. It has been modified somewhat 4237 from the material in RFC 821 to prevent server actions that might 4238 confuse clients or subsequent servers that do not expect a full 4239 source route implementation. 4241 Historically, for relay purposes, the forward-path may have been a 4242 source route of the form "@ONE,@TWO:JOE@THREE", where ONE, TWO, and 4243 THREE MUST be fully-qualified domain names. This form was used to 4244 emphasize the distinction between an address and a route. The 4245 mailbox (here, JOE@THREE) is an absolute address, and the route is 4246 information about how to get there. The two concepts should not be 4247 confused.[[CREF27: [5321bis]JcK 20090123: Tightened this and the next 4248 paragraph to be clear that this doesn't authorize source route use.]] 4249 If source routes are used contrary to requirements and 4250 recommendations elsewhere in this specfiication, RFC 821 and the text 4251 below should be consulted for the mechanisms for constructing and 4252 updating the forward-path. A server that is reached by means of a 4253 source route (e.g., its domain name appears first in the list in the 4254 forward-path) MUST remove its domain name from any forward-paths in 4255 which that domain name appears before forwarding the message and MAY 4256 remove all other source routing information. The reverse-path SHOULD 4257 NOT be updated by servers conforming to this specification. 4259 Notice that the forward-path and reverse-path appear in the SMTP 4260 commands and replies, but not necessarily in the message. That is, 4261 there is no need for these paths and especially this syntax to appear 4262 in the "To:" , "From:", "CC:", etc. fields of the message header 4263 section. Conversely, SMTP servers MUST NOT derive final message 4264 routing information from message header fields. 4266 When the list of hosts is present despite the recommendations and 4267 requirements [[CREF28: [5321bis]JcK 20090123 "and requrements" 4268 added]] above, it is a "reverse" source route and indicates that the 4269 mail was relayed through each host on the list (the first host in the 4270 list was the most recent relay). This list is used as a source route 4271 to return non-delivery notices to the sender. If, contrary to the 4272 recommendations here, a relay host adds itself to the beginning of 4273 the list, it MUST use its name as known in the transport environment 4274 to which it is relaying the mail rather than that of the transport 4275 environment from which the mail came (if they are different). Note 4276 that a situation could easily arise in which some relay hosts add 4277 their names to the reverse source route and others do not, generating 4278 discontinuities in the routing list. This is another reason why 4279 servers needing to return a message SHOULD ignore the source route 4280 entirely and simply use the domain as specified in the Mailbox. 4282 Appendix D. Scenarios 4284 This section presents complete scenarios of several types of SMTP 4285 sessions. In the examples, "C:" indicates what is said by the SMTP 4286 client, and "S:" indicates what is said by the SMTP server. 4288 D.1. A Typical SMTP Transaction Scenario 4290 This SMTP example shows mail sent by Smith at host bar.com, and to 4291 Jones, Green, and Brown at host foo.com. Here we assume that host 4292 bar.com contacts host foo.com directly. The mail is accepted for 4293 Jones and Brown. Green does not have a mailbox at host foo.com. 4295 S: 220 foo.com Simple Mail Transfer Service Ready 4296 C: EHLO bar.com 4297 S: 250-foo.com greets bar.com 4298 S: 250-8BITMIME 4299 S: 250-SIZE 4300 S: 250-DSN 4301 S: 250 HELP 4302 C: MAIL FROM: 4303 S: 250 OK 4304 C: RCPT TO: 4305 S: 250 OK 4306 C: RCPT TO: 4307 S: 550 No such user here 4308 C: RCPT TO: 4309 S: 250 OK 4310 C: DATA 4311 S: 354 Start mail input; end with . 4312 C: Blah blah blah... 4313 C: ...etc. etc. etc. 4314 C: . 4315 S: 250 OK 4316 C: QUIT 4317 S: 221 foo.com Service closing transmission channel 4319 D.2. Aborted SMTP Transaction Scenario 4321 S: 220 foo.com Simple Mail Transfer Service Ready 4322 C: EHLO bar.com 4323 S: 250-foo.com greets bar.com 4324 S: 250-8BITMIME 4325 S: 250-SIZE 4326 S: 250-DSN 4327 S: 250 HELP 4328 C: MAIL FROM: 4329 S: 250 OK 4330 C: RCPT TO: 4331 S: 250 OK 4332 C: RCPT TO: 4333 S: 550 No such user here 4334 C: RSET 4335 S: 250 OK 4336 C: QUIT 4337 S: 221 foo.com Service closing transmission channel 4339 D.3. Relayed Mail Scenario 4341 Step 1 -- Source Host to Relay Host 4343 The source host performs a DNS lookup on XYZ.COM (the destination 4344 address) and finds DNS MX records specifying xyz.com as the best 4345 preference and foo.com as a lower preference. It attempts to open a 4346 connection to xyz.com and fails. It then opens a connection to 4347 foo.com, with the following dialogue: 4349 S: 220 foo.com Simple Mail Transfer Service Ready 4350 C: EHLO bar.com 4351 S: 250-foo.com greets bar.com 4352 S: 250-8BITMIME 4353 S: 250-SIZE 4354 S: 250-DSN 4355 S: 250 HELP 4356 C: MAIL FROM: 4357 S: 250 OK 4358 C: RCPT TO: 4359 S: 250 OK 4360 C: DATA 4361 S: 354 Start mail input; end with . 4362 C: Date: Thu, 21 May 1998 05:33:29 -0700 4363 C: From: John Q. Public 4364 C: Subject: The Next Meeting of the Board 4365 C: To: Jones@xyz.com 4366 C: 4367 C: Bill: 4368 C: The next meeting of the board of directors will be 4369 C: on Tuesday. 4370 C: John. 4371 C: . 4372 S: 250 OK 4373 C: QUIT 4374 S: 221 foo.com Service closing transmission channel 4376 Step 2 -- Relay Host to Destination Host 4378 foo.com, having received the message, now does a DNS lookup on 4379 xyz.com. It finds the same set of MX records, but cannot use the one 4380 that points to itself (or to any other host as a worse preference). 4381 It tries to open a connection to xyz.com itself and succeeds. Then 4382 we have: 4384 S: 220 xyz.com Simple Mail Transfer Service Ready 4385 C: EHLO foo.com 4386 S: 250 xyz.com is on the air 4387 C: MAIL FROM: 4388 S: 250 OK 4389 C: RCPT TO: 4390 S: 250 OK 4391 C: DATA 4392 S: 354 Start mail input; end with . 4393 C: Received: from bar.com by foo.com ; Thu, 21 May 1998 4394 C: 05:33:29 -0700 4395 C: Date: Thu, 21 May 1998 05:33:29 -0700 4396 C: From: John Q. Public 4397 C: Subject: The Next Meeting of the Board 4398 C: To: Jones@xyz.com 4399 C: 4400 C: Bill: 4401 C: The next meeting of the board of directors will be 4402 C: on Tuesday. 4403 C: John. 4404 C: . 4405 S: 250 OK 4406 C: QUIT 4407 S: 221 xyz.com Service closing transmission channel 4409 D.4. Verifying and Sending Scenario 4411 S: 220 foo.com Simple Mail Transfer Service Ready 4412 C: EHLO bar.com 4413 S: 250-foo.com greets bar.com 4414 S: 250-8BITMIME 4415 S: 250-SIZE 4416 S: 250-DSN 4417 S: 250-VRFY 4418 S: 250 HELP 4419 C: VRFY Crispin 4420 S: 250 Mark Crispin 4421 C: MAIL FROM: 4422 S: 250 OK 4423 C: RCPT TO: 4424 S: 250 OK 4425 C: DATA 4426 S: 354 Start mail input; end with . 4427 C: Blah blah blah... 4428 C: ...etc. etc. etc. 4429 C: . 4430 S: 250 OK 4431 C: QUIT 4432 S: 221 foo.com Service closing transmission channel 4434 Appendix E. Other Gateway Issues 4436 In general, gateways between the Internet and other mail systems 4437 SHOULD attempt to preserve any layering semantics across the 4438 boundaries between the two mail systems involved. Gateway- 4439 translation approaches that attempt to take shortcuts by mapping 4440 (such as mapping envelope information from one system to the message 4441 header section or body of another) have generally proven to be 4442 inadequate in important ways. Systems translating between 4443 environments that do not support both envelopes and a header section 4444 and Internet mail must be written with the understanding that some 4445 information loss is almost inevitable. 4447 Appendix F. Deprecated Features of RFC 821 4449 A few features of RFC 821 have proven to be problematic and SHOULD 4450 NOT be used in Internet mail. Some of these features were deprecated 4451 in RFC 2821 in 2001; source routing and two-digit years in dates were 4452 deprecated by RFC 1123 in 1989. Of the domain literal forms, RFC 4453 1123 required support only for the dotted decimal form. With the 4454 possible exception of old, hardware-embedded, applications, there is 4455 no longer any excuse for these features to appear on the contemporary 4456 Internet. [[CREF29: [5321bis] (2821ter) 2821bis Last Call Comment]] 4458 F.1. TURN 4460 This command, described in RFC 821, raises important security issues 4461 since, in the absence of strong authentication of the host requesting 4462 that the client and server switch roles, it can easily be used to 4463 divert mail from its correct destination. Its use is deprecated; 4464 SMTP systems SHOULD NOT use it unless the server can authenticate the 4465 client. 4467 F.2. Source Routing 4469 RFC 821 utilized the concept of explicit source routing to get mail 4470 from one host to another via a series of relays. The requirement to 4471 utilize source routes in regular mail traffic was eliminated by the 4472 introduction of the domain name system "MX" record and the last 4473 significant justification for them was eliminated by the 4474 introduction, in RFC 1123, of a clear requirement that addresses 4475 following an "@" must all be fully-qualified domain names. 4476 Consequently, the only remaining justifications for the use of source 4477 routes are support for very old SMTP clients or MUAs and in mail 4478 system debugging. They can, however, still be useful in the latter 4479 circumstance and for routing mail around serious, but temporary, 4480 problems such as problems with the relevant DNS records. 4482 SMTP servers MUST continue to accept source route syntax as specified 4483 in the main body of this document and in RFC 1123. They MAY, if 4484 necessary, ignore the routes and utilize only the target domain in 4485 the address. If they do utilize the source route, the message MUST 4486 be sent to the first domain shown in the address. In particular, a 4487 server MUST NOT guess at shortcuts within the source route. 4489 Clients SHOULD NOT utilize explicit source routing except under 4490 unusual circumstances, such as debugging or potentially relaying 4491 around firewall or mail system configuration errors. 4493 F.3. HELO 4495 As discussed in Sections 3.1 and 4.1.1, EHLO SHOULD be used rather 4496 than HELO when the server will accept the former. Servers MUST 4497 continue to accept and process HELO in order to support older 4498 clients. 4500 F.4. #-literals 4502 RFC 821 provided for specifying an Internet address as a decimal 4503 integer host number prefixed by a pound sign, "#". In practice, that 4504 form has been obsolete since the introduction of TCP/IP. It is 4505 deprecated and MUST NOT be used. 4507 F.5. Dates and Years 4509 When dates are inserted into messages by SMTP clients or servers 4510 (e.g., in trace header fields), four-digit years MUST BE used. Two- 4511 digit years are deprecated; three-digit years were never permitted in 4512 the Internet mail system. 4514 F.6. Sending versus Mailing 4516 In addition to specifying a mechanism for delivering messages to 4517 user's mailboxes, RFC 821 provided additional, optional, commands to 4518 deliver messages directly to the user's terminal screen. These 4519 commands (SEND, SAML, SOML) were rarely implemented, and changes in 4520 workstation technology and the introduction of other protocols may 4521 have rendered them obsolete even where they are implemented. 4522 [[5321bis Editor's Note: does this need a stronger reference to 821, 4523 2821, and/or 5321?]] 4525 Clients SHOULD NOT provide SEND, SAML, or SOML as services. Servers 4526 MAY implement them. If they are implemented by servers, the 4527 implementation model specified in RFC 821 MUST be used and the 4528 command names MUST be published in the response to the EHLO command. 4530 Appendix G. Other Outstanding Issues 4532 [[RFC Editor: Please remove this section before publication.]] 4534 In December 2019, an issue was raised on the ietf-smtp@ietf.org list 4535 that led to a broad discussion of ways in which existing practice had 4536 diverged from the specifications and recommendations of RFC 5321 in 4537 the more than eleven years since it was published (some of those 4538 issues probably affect the boundary between RFC 5321 and 5322 and 4539 hence the latter as well). In most cases, those divergences call for 4540 revision of the Technical Specification to match the practice, 4541 clarification of the specification text in other ways, or a more 4542 comprehensive explanation of why the practices recommended by the 4543 specification should really be followed. 4545 Those discussions raised two other issues, which were that 4547 o The publication of the Submission Server specification of RFC 6409 4548 in November 2011 may not have been fully reflected in RFC 5321 4549 (despite the even earlier publication of RFC 4409) and 4551 o There may be inconsistencies between the July 2009 Internet Mail 4552 Architecture description of RFC 5598 and the model described in 4553 RFC 5321. The issue called out in Appendix G.3 below may be an 4554 example of one of those inconsistencies. 4556 Those discrepancies should be identified and discussed and decisions 4557 made to fix them (and where) or to ignore them and let them continue. 4559 There has also been discussion on the mailing list, perhaps amounting 4560 to very rough consensus, that any revision of RFC 5321 and/or 5322 4561 should be accompanied by a separate Applicability Statement document 4562 that would make recommendations about applicability or best practices 4563 in particular areas rather than trying to get everything into the two 4564 technical specifications. This appendix does not attempt to identify 4565 which issues should get which treatment. 4567 Until and unless there is a WG with appropriate leadership and 4568 tracking mechanisms, this appendix will act as a temporary record of 4569 issues that should be discussed and decided upon before a revised 4570 SMTP specification (or a related Applicability Statement) is 4571 published, issues that have not been reflected in errata (see 4572 Appendix H.1 below for those covered by errata). 4574 G.1. IP Address Literals 4576 The specification is unclear about whether IP address literals, 4577 particularly IP address literals used as arguments to the EHLO 4578 command, are required to be accepted or whether they are allowed to 4579 be rejected as part of the general "operational necessity" exception. 4580 Some have suggested that rejection of them is so common as an anti- 4581 spam measure that the use of such literals should be deprecated 4582 entirely in the specification, others that the are still useful and 4583 used and/or that, whatever is said about IP address literals within 4584 an SMTP session (e.g., in MAIL or RCPT commands), they should 4585 continue to be allowed (and required) in EHLO. 4587 G.2. Repeated Use of EHLO 4589 While the specification says that an SMTP client's sending EHLO again 4590 after it has been issued (starting an SMTP session and treats it as 4591 if RSET had been sent (closing the session) followed by EHLO, there 4592 are apparently applications, at least some of them involving setting 4593 up of secure connections, in which the second EHLO is required and 4594 does not imply RSET. Does the specification need to be adjusted to 4595 reflect or call out those cases? 4597 G.3. Meaning of "MTA" and Related Terminology 4599 A terminology issue has come up about what the term "MTA" actually 4600 refers to, a question that became at least slightly more complicated 4601 when we formalized RFC 6409 Submission Servers. Does the document 4602 need to be adjusted to be more clear about this topic? Note that the 4603 answer may interact with the question asked in Section 2 above. 4604 Possibly along the same lines, RFC 2821 changed the RFC 821 4605 terminology from "sender-SMTP" and "receiver-SMTP" to "SMTP client" 4606 and "SMTP server" respectively. As things have evolved, it is 4607 possible that newer terminology is a source of confusion and that the 4608 terminology should be changed back, something that also needs 4609 discussion. 4611 G.4. Originator, or Originating System, Authentication 4613 Should RFC 5321bis address authentication and related issues or 4614 should Section 3.9 or other text be reshaped (in addition to or 4615 instead of the comment on that section) to lay a better foundation 4616 for such work, either in the context of mailing lists or more 4617 generally? 4619 G.5. Remove or deprecate the work-around from code 552 to 452 4621 The suggestion in Section 4.5.3.1.10 may have outlived its usefulness 4622 and/or be inconsistent with current practice. Should it be removed 4623 and/or explicitly deprecated? 4625 G.6. Clarify where the protocol stands with respect to submission and 4626 TLS issues 4628 1. submission on port 587 4630 2. submission on port 465 4632 3. TLS relay on a port different from 25 (whenever) 4634 G.7. Probably-substantive Discussion Topics Identified in Other Ways 4636 The following issues were identified as a group in the opening Note 4637 but called out specifically only in embedded CREF comments in earlier 4638 (-00 and -01) versions of this draft. 4640 G.7.1. Issues with 521, 554, and 556 codes 4642 See new Section 4.2.4.2. 4644 G.7.2. SMTP Model, terminology, and relationship to RFC 5598 4646 CREF comment in Section 2 and also CREF comment in Section 2.3.10 4648 G.7.3. Resolvable FQDNs and private domain names 4650 Multiple CREF comments in Section 2.3.5 4652 G.7.4. Possible clarification about mail transactions and transaction 4653 state 4655 CREF comment in Section 3.3 and also reference in Section 4.1.4 4657 G.7.5. Issues with mailing lists, aliases, and forwarding 4659 CREF comment in Section 3.9. May also want to note forwarding as an 4660 email address portability issue. 4662 G.7.6. Requirements for domain name and/or IP address in EHLO 4664 CREF comment in Section 4.1.4 4666 G.7.7. Does the 'first digit only' and/or non-listed reply code text 4667 need clarification? 4669 CREF comments in Section 4.2 and Section 4.3.1 4671 G.7.8. Size limits 4673 CREF comment in Section 4.5.3 4675 G.7.9. Discussion of 'blind' copies and RCPT 4677 CREF comment in Section 7.2. May alto need to discussion whether 4678 that terminology is politically incorrect and suggest a replacement. 4680 G.7.10. Further clarifications needed to source routes? 4682 CREF comment in Appendix C 4684 Appendix H. Change log for RFC 5321bis 4686 [[RFC Editor: Please remove this section before publication.]] 4688 H.1. RFC 5321 Errata Summary 4690 This document addresses the following errata filed against RFC 5321 4691 since its publication in October 2008 [52] [[CREF30: [[Note in Draft: 4692 Items with comments below have not yet been resolved.]]]] 4694 1683 ABNF error. Section 4.4 4696 4198 Description error. Section 4.2 4698 2578 Syntax description error. Section 4.1.2 4700 1543 Wrong code in description Section 3.8 4702 4315 ABNF - IPv6 Section 4.1.3. [[CREF31: [5321bis]The IPv6 syntax 4703 has been adjusted since 5321 was published. See the rewritten 4704 form and the comment in the section cited in the previous 4705 sentence. The editor awaits instructions. See https://www.rfc- 4706 editor.org/errata/eid4315]] 4708 5414 ABNF for Quoted-string Section 4.1.2 4710 1851 Location of text on unexpected close Section 4.1.1.5. 4711 [[CREF32: [5321bis]Matter of taste, editor seeks advice.]] 4713 3447 Use of normative language (e.g., more "MUST"s), possible 4714 confusion in some sections Section 4.4. [[CREF33: [5321bis]As 4715 Barry notes in his verifier comments on the erratum (see 4716 https://www.rfc-editor.org/errata/eid3447), the comments and 4717 suggestions here raise a number of interesting (and difficult) 4718 issues. One of the issues is that the core of RFCs 5321 (and 4719 2821) is text carried over from Jon Postel's RFC 821, a document 4720 that was not only written in a different style than the IETF uses 4721 today but that was written at a time when no one had dreamt of RFC 4722 2119 or even the IETF itself. It appears to me that trying to 4723 patch that style might easily result in a document that is harder 4724 to read as well as being error prone. If we want to get the 4725 document entirely into contemporary style, we really should bite 4726 the bullet and do a complete rewrite. To respond to a different 4727 point in Barry's discussion, I think an explicit statement that 4728 5321/5322 and their predecessors differ in places and why would be 4729 helpful. Text, and suggestions about where to put it, are 4730 solicited. A list of differences might be a good idea too, but 4731 getting it right might be more work than there is available energy 4732 to do correctly. ]] 4734 5711 Missing leading spaces in example Appendix D.3. [[CREF34: 4735 [5321bis]Well, this is interesting because the XML is correct and 4736 the spaces are there, embedded in artwork. So either the XML2RFC 4737 processor at the time took those leading spaces out or the RFC 4738 Editor improved on the document and the change was not caught in 4739 AUTH48, perhaps because rfcdiff ignores white space. We just need 4740 to watch for future iterations. ]] 4742 [[CREF35: [5321bis]Note that rejected errata have _not_ been reviewed 4743 to see if they contain anything useful that should be discussed again 4744 with the possibility of rethinking and changing text. Volunteers 4745 sought.]] 4747 H.2. Changes from RFC 5321 (published October 2008) to the initial 4748 (-00) version of this draft 4750 o Acknowledgments section (Section 9) trimmed back for new document. 4752 o Introductory paragraph to Appendix F extended to make it clear 4753 that these features were deprecated a long time ago and really 4754 should not be in use any more. 4756 o Adjusted some language to clarify that source routes really, 4757 really, should not be used or depended upon. 4759 o IPv6 address syntax replaced by a copy of the IPv6 URI syntax and 4760 a note added. 4762 o Production index added as a first step in tying all productions to 4763 their sources. As part of the effort to make the document more 4764 easily navigable, table of contents entries have been created for 4765 the individual command descriptions. 4767 o Clarified the relationship between the SMTP "letters, digits, and 4768 hyphens" and DNS "preferred name syntax" (Section 2.3.5). 4770 o Revised the reply code sections to add new 521 and 556 codes, 4771 clarify relationships, and be explicit about the requirement for 4772 clients to rely on first digits rather than the sequences in 4773 Section 4.3.2. 4775 o In conjunction with the above, explicitly obsolete RFCs 1846 and 4776 7504. 4778 o Incorporated a correction reflecting Errata ID 2578. 4780 o Some small editorial changes made to eliminate redundant 4781 statements that were very close together. Other, equally small, 4782 editorial changes have been made to improve grammar or clarity. 4784 o A few questions, marked "[[5321bis Editor's Note:", or "[[Note in 4785 Draft" have been added for the group to resolve. Other questions, 4786 especially those in the errata summary, are simply included in 4787 narrative comments in CREFs. 4789 o Checked and rationalized "response" (to a command) and "reply 4790 code" terminology. One can talk about a "999 response" but only a 4791 "999 reply code". There is no such thing as a "response code". 4793 o Added note about length limit on mailbox names ("email 4794 addresses"). 4796 o Added an "errata summary" subsection to this change log/ 4797 comparison to 5321 in this Appendix. The entire Appendix will, of 4798 course, disappear at the time of RFC publication unless someone 4799 wants to make a strong case for retaining it. 4801 o Rationalized CREFs to 2821, 5321, 5321bis etc.; added note to 4802 readers below the Abstract. 4804 o Temporarily added a "Note on Reading This Working Draft" after the 4805 Abstract. 4807 H.3. Changes Among Versions of Rfc5321bis 4809 H.3.1. Changes from draft-klensin-rfc5321bis-00 (posted 2012-12-02) to 4810 -01 4812 Substantively, these two versions differ only by suppression of the 4813 CREF and other discussion associated with the evolution from RFC 2821 4814 to RFC 5321. That change includes an update to the document's Note 4815 to Readers, the date, the file name, and the addition of this change 4816 log subsection. 4818 H.3.2. Changes from draft-klensin-rfc5321bis-01 (20191203) to -02 4820 o Minor clarifications to improve text, e.g., addition of NOOP to 4821 the list of non-mail transaction examples in Section 4.1.4. 4823 o Added topics exposed in the ietf-smtp list and the IETF list 4824 "dogfood" discussion during December 2019 and an index listing of 4825 substantive issues identified only in CREFs in the prior draft as 4826 a new Appendix G.. 4828 Index 4830 A 4831 Argument Syntax 4832 A-d-l 42 4833 Additional-Registered-Clauses 62 4834 address-literal 42 4835 Addtl-Link 63 4836 Addtl-Protocol 63 4837 Argument 42 4838 At-domain 42 4839 Atom 42 4840 By-domain 62 4841 dcontent 44 4842 Domain 42 4843 Dot-string 42 4844 esmtp-keyword 42 4845 esmtp-param 42 4846 esmtp-value 42 4847 Extended-Domain 62 4848 For 62 4849 Forward-Path 41 4850 From-domain 62 4851 General-address-literal 44 4852 Greeting 48 4853 h16 45 4854 ID 62 4855 IPv4-address-literal 44 4856 IPv6-addr 45 4857 IPv6-address-literal 44 4858 Keyword 42 4859 Ldh-str 42 4860 Let-dig 42 4861 Link 62 4862 Local-part 42 4863 ls32 45 4864 Mail-parameters 42 4865 Mailbox 42 4866 Opt-info 62 4867 Path 41 4868 Protocol 63 4869 QcontentSMTP 43 4870 qtextSMTP 43 4871 quoted-pairSMTP 43 4872 Quoted-string 43 4873 Rcpt-parameters 42 4874 Reply-code 48 4875 Reply-line 48 4876 Return-path-line 61 4877 Reverse-Path 41 4878 Snum 44 4879 Stamp 62 4880 Standardized-tag 44 4881 String 43 4882 sub-domain 42 4883 TCP-info 62 4884 textstring 48 4885 Time-stamp-line 62 4886 Via 62 4887 With 62 4889 C 4890 Command Syntax 4891 data 38 4892 expn 40 4893 help 40 4894 mail 36 4895 noop 40 4896 quit 41 4897 rcpt 37 4898 rset 39 4899 vrfy 39 4901 Author's Address 4903 John C. Klensin 4904 1770 Massachusetts Ave, Suite 322 4905 Cambridge, MA 02140 4906 USA 4908 EMail: john-ietf@jck.com