RFC 3461

Simple Mail Transfer Protocol (SMTP) Service Extension for Delivery Status Notifications (DSNs)

๐Ÿ“… published January 2003, from ietf

RFC 3461: Simple Mail Transfer Protocol (SMTP) Service Extension for Delivery Status Notifications (DSNs) ๐Ÿ’Œ

Okay bestie, let's do the vibe check first ๐Ÿงš This is RFC 3461, a Standards Track doc, so it's an official Internet protocol spec. K. Moore from the University of Tennessee wrote it, it lives in the Network Working Group, and it was published in January 2003. It also obsoletes RFC 1891 โœจ, so this is the newer, upgraded version of that one. It doesn't list any updates, fr.

Status of This Memo ๐ŸŽ€

This doc specifies an Internet standards track protocol for the Internet community, and it's literally asking people to talk about it and send over suggestions for improvements ๐Ÿ’ฌ For where this protocol stands in standardization, check the current edition of the "Internet Official Protocol Standards" (STD 1) ๐Ÿ“š And the best part: distribution of this memo is unlimited ๐ŸŒˆ

Copyright (C) The Internet Society (2003). All Rights Reserved.

Abstract ๐ŸŒธ

This memo defines an extension to the Simple Mail Transfer Protocol (SMTP) service. It lets an SMTP client spell out three things:

  • (a) the conditions under which Delivery Status Notifications (DSNs) should be generated,
  • (b) whether those notifications should return the contents of the message, and
  • (c) extra info that comes back with a DSN, letting the sender identify both the recipient(s) the DSN was issued for and the transaction the original message was sent in. ๐Ÿ’…

Terminology ๐Ÿ’œ

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14, RFC 2119 [7]. So these words are the official rulebook vocab, periodt ๐Ÿ“œ

Table of Contents ๐Ÿ“–

1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . .  3
2. Framework for the Delivery Status Notification Extension . . .  4
3. The Delivery Status Notification service extension . . . . . .  5
4. Additional parameters for RCPT and MAIL commands . . . . . . .  6
4.1 The NOTIFY parameter of the ESMTP RCPT command. . . . . . . .  7
4.2 The ORCPT parameter to the ESMTP RCPT command . . . . . . . .  8
4.3 The RET parameter of the ESMTP MAIL command . . . . . . . . .  9
4.4 The ENVID parameter to the ESMTP MAIL command . . . . . . . .  9
4.5 Restrictions on the use of Delivery Status Notification
    parameters. . . . . . . . . . . . . . . . . . . . . . . . . . 10
5. Conformance requirements . . . . . . . . . . . . . . . . . . . 10
5.1 SMTP protocol interactions. . . . . . . . . . . . . . . . . . 11
5.2 Handling of messages received via SMTP. . . . . . . . . . . . 11
5.2.1 Relay of messages to other conforming SMTP servers. . . . . 12
5.2.2 Relay of messages to non-conforming SMTP servers. . . . . . 13
5.2.3 Local delivery of messages. . . . . . . . . . . . . . . . . 14
5.2.4 Gatewaying a message into a foreign environment . . . . . . 14
5.2.5 Delays in delivery. . . . . . . . . . . . . . . . . . . . . 15
5.2.6 Failure of a conforming MTA to deliver a message. . . . . . 16
5.2.7 Forwarding, aliases, and mailing lists. . . . . . . . . . . 16
5.2.7.1 mailing lists . . . . . . . . . . . . . . . . . . . . . . 17
5.2.7.2 single-recipient aliases. . . . . . . . . . . . . . . . . 18
5.2.7.3 multiple-recipient aliases. . . . . . . . . . . . . . . . 18
5.2.7.4 confidential forwarding addresses . . . . . . . . . . . . 18
5.2.8 DSNs describing delivery to multiple recipients . . . . . . 19
5.3 Handling of messages from other sources . . . . . . . . . . . 19
5.4 Implementation limits . . . . . . . . . . . . . . . . . . . . 19
6. Format of delivery notifications . . . . . . . . . . . . . . . 20
6.1 SMTP Envelope to be used with delivery status
    notifications . . . . . . . . . . . . . . . . . . . . . . . . 20
6.2 Contents of the DSN . . . . . . . . . . . . . . . . . . . . . 20
6.3 Message/delivery-status fields. . . . . . . . . . . . . . . . 21
7. Acknowledgments. . . . . . . . . . . . . . . . . . . . . . . . 22
8. Security Considerations. . . . . . . . . . . . . . . . . . . . 22
9. Appendix - Type-Name Definitions . . . . . . . . . . . . . . . 24
9.1 "rfc822" address-type . . . . . . . . . . . . . . . . . . . . 24
9.2 "smtp" diagnostic-type. . . . . . . . . . . . . . . . . . . . 24
9.3 "dns" MTA-name-type . . . . . . . . . . . . . . . . . . . . . 25
10. Appendix - Example. . . . . . . . . . . . . . . . . . . . . . 26
10.1 Submission . . . . . . . . . . . . . . . . . . . . . . . . . 27
10.2 Relay to Example.COM . . . . . . . . . . . . . . . . . . . . 28
10.3 Relay to Ivory.EDU . . . . . . . . . . . . . . . . . . . . . 29
10.4 Relay to Bombs.AF.MIL. . . . . . . . . . . . . . . . . . . . 30
10.5 Forward from George@Tax-ME.GOV to Sam@Boondoggle.GOV . . . . 31
10.6 "Delivered" DSN for Bob@Example.COM. . . . . . . . . . . . . 32
10.7 Failed DSN for Carol@Ivory.EDU . . . . . . . . . . . . . . . 33
10.8 Relayed DSN For Dana@Ivory.EDU . . . . . . . . . . . . . . . 34
10.9 Failure notification for Sam@Boondoggle.GOV. . . . . . . . . 35
11. Appendix - Changes since RFC 1891 . . . . . . . . . . . . . . 35
12. References. . . . . . . . . . . . . . . . . . . . . . . . . . 36
12.1 Normative References . . . . . . . . . . . . . . . . . . . . 36
12.2 Informative References . . . . . . . . . . . . . . . . . . . 36
13. Author's Address. . . . . . . . . . . . . . . . . . . . . . . 37
14. Full Copyright Statement. . . . . . . . . . . . . . . . . . . 38

1. Introduction โœจ

So the SMTP protocol [1] says an SMTP server has to tell people when delivery fails, if it figures out a message can't reach one or more recipients ๐Ÿ“ฌ Usually that notice is a regular Internet mail message (format defined by [2]) sent to the envelope sender address (the argument of the SMTP MAIL command). It explains the error and includes at least the headers of the failed message.

Experience with large mail distribution lists [8] shows those messages are often not enough to diagnose problems, or even to figure out which host or which recipients had the issue ๐Ÿ˜ญ Plus, since Internet mail has no standardized format for delivery notifications, it's hard to pass them along to other message handling systems ๐Ÿ™ƒ

Such experience has shown a need for a delivery status notification service for Internet electronic mail that:

  • (a) is reliable, in the sense that any DSN request will either be honored at the time of final delivery, or result in a response that indicates that the request cannot be honored,
  • (b) when both success and failure notifications are requested, provides an unambiguous and nonconflicting indication of whether delivery of a message to a recipient succeeded or failed,
  • (c) is stable, in that a failed attempt to deliver a DSN should never result in the transmission of another DSN over the network,
  • (d) preserves sufficient information to allow the sender to identify both the mail transaction and the recipient address which caused the notification, even when mail is forwarded or gatewayed to foreign environments, and
  • (e) interfaces acceptably with non-SMTP and non-822-based mail systems, both so that notifications returned from foreign mail systems may be useful to Internet users, and so that the notification requests from foreign environments may be honored. Among the requirements implied by this goal are the ability to request non-return-of-content, and the ability to specify whether positive delivery notifications, negative delivery notifications, both, or neither, should be issued. ๐Ÿ”ฅ

To make this happen, this memo uses the mechanism defined in [1] to add an extension to SMTP. With it, an SMTP client can ask an SMTP server to issue or not issue a Delivery Status Notification (DSN) under certain conditions ๐Ÿ’– The format of a DSN is defined in [3].

2. Framework for the Delivery Status Notification Extension ๐Ÿ’…

Here's the lineup of the service extension being defined:

  • (1) The name of the SMTP service extension is Delivery Status Notification;
  • (2) the EHLO keyword value associated with this extension is DSN, the meaning of which is defined in section 3 of this memo;
  • (3) no parameters are allowed with this EHLO keyword value;
  • (4) two optional parameters are added to the RCPT command, and two optional parameters are added to the MAIL command:
    • An optional parameter for the RCPT command, using the esmtp-keyword NOTIFY, (to specify the conditions under which a Delivery Status Notification should be generated), is defined in section 5.1,
    • An optional parameter for the RCPT command, using the esmtp-keyword ORCPT, (used to convey the "original" (sender-specified) recipient address), is defined in section 5.2, and
    • An optional parameter for the MAIL command, using the esmtp-keyword RET, (to request that DSNs containing an indication of delivery failure either return the entire contents of a message or only the message headers), is defined in section 5.3,
    • An optional parameter for the MAIL command, using the esmtp-keyword ENVID, (used to propagate an identifier for this message transmission envelope, which is also known to the sender and will, if present, be returned in any DSNs issued for this transmission), is defined in section 4.4;
  • (5) no additional SMTP verbs are defined by this extension.

The rest of this memo spells out how support for the extension affects the behavior of a message transfer agent. ๐Ÿฆ‹

More of this RFC is coming in part 2, bestie, so stay tuned ๐Ÿงš๐Ÿ’œ

3. The Delivery Status Notification service extension โœจ

okay so an SMTP client that wants to request a DSN starts the session with the EHLO command, which lets it check whether the server supports any of the service extensions ๐Ÿ’… If the server replies to EHLO with code 250 and the response includes the EHLO keyword DSN, then the Delivery Status Notification extension (as described in this memo) is supported ๐ŸŽ€

ngl this is the part where it gets fun ๐Ÿ‘‘ Normally, when an SMTP server sends back a positive (2xx) reply code to a RCPT command, it's basically promising to either deliver the message to the named recipient, or send a notification to the sender saying delivery failed ๐Ÿซถ But an extended SMTP ("ESMTP") server that implements this service extension will accept an optional NOTIFY parameter with the RCPT command ๐Ÿฆ‹ If that parameter is there, it changes the rules for when DSNs get generated, away from the default (issue notifications only on failure) specified in [1] ๐Ÿ’œ The ESMTP client can also ask (via the RET parameter) whether the entire contents of the original message should come back with the DSN, or just the headers ๐Ÿ“จ

the vibe here is main character energy for relaying ๐ŸŒธ In general, an ESMTP server that implements this extension will pass along Delivery Status Notification requests when it relays mail to other SMTP-based MTAs that also support this extension, and it makes a "best effort" to make sure those requests get honored when messages move into other environments ๐Ÿงš

now, for DSNs to actually mean something to the sender, ESMTP servers that support this extension should pass along the following info to any other MTAs used to relay the message ๐Ÿ“

(a) for each recipient, a copy of the original recipient address, exactly as the sender used it.

This address doesn't have to match the mailbox in the RCPT command ๐Ÿ™ˆ Like, if a message was originally addressed to A@B.C and then got forwarded to A@D.E, the RCPT command will name A@D.E after the forwarding happens. But the original recipient address is still A@B.C ๐Ÿ’–

Also, if the message came from an environment that doesn't use Internet-style user@domain addresses, and got gatewayed into SMTP, the original recipient address keeps the original form of that recipient address โœจ

(b) for the entire SMTP transaction, an envelope identification string ๐Ÿฆ‹ The sender can use it to tie any delivery status notifications back to the transaction that was used to send the original message ๐Ÿ”ฅ

4. Additional parameters for RCPT and MAIL commands ๐ŸŽ€

so the extended RCPT and MAIL commands are what a client sends when it wants the server to issue a DSN for a particular recipient under certain conditions ๐Ÿ’… They work exactly like the RCPT and MAIL commands defined in [1], except one or more of the following parameters show up after the sender or recipient address, respectively ๐ŸŒˆ The general syntax for extended SMTP commands is defined in [1] too, so that's where to look for the basics โœจ

NOTE: Even though RFC 822 ABNF is used to describe the syntax of these parameters, they are not "structured field bodies" in that document's language ๐Ÿ’€ So while parentheses MAY appear within an emstp-value, they are not recognized as comment delimiters ๐Ÿ™ˆ

here's the thing about values ๐Ÿ‘€ The syntax for "esmtp-value" in [1] doesn't allow SP, "=", control characters, or characters outside the traditional ASCII range of 1-127 decimal to be sent in an esmtp-value. But the ENVID and ORCPT parameters might need to carry values outside that range, so their esmtp-values get encoded as "xtext" ๐Ÿซถ "xtext" is formally defined like this:

xtext = *( xchar / hexchar )

xchar = any ASCII CHAR between "!" (33) and "~" (126) inclusive,
        except for "+" and "=".

; "hexchar"s are intended to encode octets that cannot appear
; as ASCII characters within an esmtp-value.

hexchar = ASCII "+" immediately followed by two upper case
          hexadecimal digits

when you're encoding an octet sequence as xtext, here's the deal ๐Ÿง

  • Any ASCII CHAR between "!" and "~" inclusive, except for "+" and "=", MAY be encoded as itself. (A CHAR in this range MAY instead be encoded as a "hexchar", at the implementor's discretion.) ๐Ÿ’–
  • ASCII CHARs that fall outside the range above must be encoded as "hexchar". ๐Ÿ”ฅ

4.1 The NOTIFY parameter of the ESMTP RCPT command ๐Ÿ’…

a RCPT command sent by a client may include the optional esmtp-keyword "NOTIFY", which says under what conditions the SMTP server should generate DSNs for that recipient ๐Ÿฆ‹ If the NOTIFY esmtp-keyword is used, it MUST have an associated esmtp-value, formatted using the rules below, with the ABNF of RFC 822 ๐ŸŽ€

notify-esmtp-value = "NEVER" / 1#notify-list-element

notify-list-element = "SUCCESS" / "FAILURE" / "DELAY"

Notes:

a. Multiple notify-list-elements, separated by commas, MAY appear in a NOTIFY parameter ๐ŸŒธ however, the NEVER keyword MUST appear by itself ๐Ÿ™…โ€โ™€๏ธ

b. Any of the keywords NEVER, SUCCESS, FAILURE, or DELAY can be spelled in any mix of upper and lower case letters ๐ŸŒˆ

here's what the NOTIFY values generally mean ๐Ÿงš

  • A NOTIFY parameter value of "NEVER" asks that a DSN not be returned to the sender under any conditions. ๐Ÿ’€
  • A NOTIFY parameter value containing the "SUCCESS" or "FAILURE" keywords asks that a DSN be issued on successful delivery or delivery failure, respectively. ๐Ÿซถ
  • A NOTIFY parameter value containing the keyword "DELAY" shows the sender is willing to receive "delayed" DSNs. Delayed DSNs may be issued if delivery of a message has been held up for an unusual amount of time (as decided by the MTA where the message got delayed), but the final delivery status (success or failure) can't be figured out yet โณ Leaving DELAY out of a NOTIFY parameter means a "delayed" DSN NOT be issued under any conditions ๐Ÿ™…โ€โ™€๏ธ

the actual rules for how the NOTIFY parameter gets interpreted are in section 6 ๐Ÿ“–

for compatibility with SMTP clients that don't use the NOTIFY facility, not including a NOTIFY parameter in a RCPT command may be interpreted as either NOTIFY=FAILURE or NOTIFY=FAILURE,DELAY ๐Ÿคทโ€โ™€๏ธโœจ

4.2 The ORCPT parameter to the ESMTP RCPT command ๐ŸŽ€

the ORCPT esmtp-keyword of the RCPT command is used to name an "original" recipient address that matches the actual recipient the message is going to ๐Ÿ’– If the ORCPT esmtp-keyword is used, it MUST have an associated esmtp-value, which is the original recipient address encoded using the rules below ๐Ÿฆ‹ The ABNF for the ORCPT parameter is:

orcpt-parameter = "ORCPT=" original-recipient-address

original-recipient-address = addr-type ";" xtext

addr-type = atom

the "addr-type" portion MUST be an IANA-registered electronic mail address-type (as defined in [3]), while the "xtext" portion holds an encoded version of the original recipient address, using the rules in section 5 of this document ๐Ÿงš The entire ORCPT parameter MAY be up to 500 characters long ๐Ÿ“

when a message is first submitted via SMTP and the ORCPT parameter is used, it MUST contain the same address as the RCPT TO address ๐Ÿ’… (Unlike the RCPT TO address, the ORCPT parameter gets encoded as xtext.) Likewise, when a mailing list submits a message via SMTP to be sent out to the list subscribers, if ORCPT is used, the ORCPT parameter MUST match the new RCPT TO address of each recipient, not the address the original sender specified ๐ŸŒธ)

the "addr-type" portion of the original-recipient-address tells you the "type" of address in the ORCPT parameter value ๐Ÿ” But the address tied to the ORCPT keyword is NOT constrained to follow the syntax rules for that "addr-type" ๐Ÿ™ˆ

ideally, the "xtext" portion of the original-recipient-address should hold, in encoded form, the same characters the sender used to specify the recipient ๐Ÿ“ But for a message gatewayed from an environment (like X.400) where a recipient address isn't just a simple string of printable characters, the representation of the recipient address must be defined by a spec for gatewaying between DSNs and that environment ๐ŸŒˆ

because of limits in the Delivery Status Notification format, the value of the original recipient address before it's encoded as "xtext" MUST consist entirely of printable (graphic and white space) characters from the US-ASCII [4] repertoire ๐Ÿ’€ If an addr-type is defined for addresses that use characters outside that repertoire, the specification for that addr-type MUST define the means of encoding those addresses in printable US-ASCII characters when are then encoded as xtext ๐Ÿซถ

4.3 The RET parameter of the ESMTP MAIL command ๐Ÿ’Œ

the RET esmtp-keyword on the extended MAIL command says whether or not the message should be included in any failed DSN issued for this message transmission ๐ŸŽ€ If the RET esmtp-keyword is used, it MUST have an associated esmtp-value, which is one of these keywords:

FULL requests that the entire message be returned in any "failed" Delivery Status Notification issued for this recipient. ๐Ÿ“ฌ

HDRS requests that only the headers of the message be returned. ๐Ÿ“ญ

the FULL and HDRS keywords can be spelled in any mix of upper and lower case letters โœจ

if no RET parameter is supplied, the MTA MAY return either the headers of the message or the entire message for any DSN containing indication of failed deliveries ๐Ÿคทโ€โ™€๏ธ

Heads up: the RET parameter only applies to DSNs that show delivery failure for at least one recipient ๐Ÿšจ If a DSN has no indications of delivery failure, only the headers of the message should be returned ๐Ÿ™

4.4 The ENVID parameter to the ESMTP MAIL command ๐Ÿฆ‹

the ENVID esmtp-keyword of the SMTP MAIL command is used to set an "envelope identifier" that gets sent along with the message and included in any DSNs issued for any of the recipients in this SMTP transaction ๐Ÿงš The whole point is so the sender can figure out which transaction a DSN came from ๐Ÿ’–

The ABNF for the ENVID parameter is:

envid-parameter = "ENVID=" xtext

the ENVID esmtp-keyword MUST have an associated esmtp-value ๐Ÿซถ The mail system doesn't assign any meaning to whether this parameter is present or absent, or to any esmtp-value tied to it. Only the sender or their user agent uses the info ๐Ÿ™Œ The ENVID parameter MAY be up to 100 characters long ๐Ÿ“

because of limits in the Delivery Status Notification format, the value of the ENVID parameter before it's encoded as "xtext" MUST consist entirely of printable (graphic and white space) characters from the US-ASCII [4] repertoire ๐Ÿ’…

4.5 Restrictions on the use of Delivery Status Notification parameters ๐Ÿ™ˆ

Okay so, bestie, there are rules about how many times each parameter can show up. The RET and ENVID parameters MUST NOT appear more than once each in any single MAIL command. If more than one of either of these parameters shows up in a MAIL command, the ESMTP server SHOULD respond with 501 syntax error in parameters or arguments.

The NOTIFY and ORCPT parameters MUST NOT appear more than once in any RCPT command. If more than one of either of these parameters shows up in a RCPT command, the ESMTP server SHOULD respond with 501 syntax error in parameters or arguments. ๐Ÿ’…


5. Conformance requirements โœจ

Okay, this is the part where we get into who has to do what. The Simple Mail Transfer Protocol (SMTP) is used by Message Transfer Agents (MTAs) when they accept, relay, or gateway mail, and by User Agents (UAs) when they submit mail to the mail transport system. The DSN extension to SMTP can be used to let UAs pass along the sender's wishes about when DSNs should be issued. A UA that claims to conform to this specification has to meet certain requirements, which are described below. ๐ŸŽ€

Typically, a message transfer agent (MTA) that supports SMTP will play both the SMTP client role and the SMTP server role at different times. It may also do local delivery, gatewaying to foreign environments, forwarding, and mailing list expansion. An MTA that, when acting as an SMTP server, issues the DSN keyword in response to the EHLO command MUST obey the rules below for a "conforming SMTP client" when it's acting as a client, and for a "conforming SMTP server" when it's acting as a server. The term "conforming MTA" refers to an MTA that conforms to this specification, no matter whether it's acting as a client or a server. ๐Ÿฆ‹


5.1 SMTP protocol interactions ๐Ÿ’œ

These rules apply to SMTP transactions where any of the ENVID, NOTIFY, RET, or ORCPT keywords are used:

(a) If an SMTP client issues a MAIL command containing a valid ENVID parameter and associated esmtp-value, and/or a valid RET parameter and associated esmtp-value, a conforming SMTP server MUST return the same reply-code it would return to the same MAIL command without the ENVID and/or RET parameters. A conforming SMTP server MUST NOT refuse a MAIL command based on whether valid ENVID or RET parameters are absent or present, or based on their associated esmtp-values. ๐ŸŒธ

However, if the associated esmtp-value isn't valid (i.e., it contains illegal characters), or if there's more than one ENVID or RET parameter in a particular MAIL command, the server MUST issue the reply-code 501 with an appropriate message (e.g., "syntax error in parameter"). ๐Ÿ˜ญ

(b) If an SMTP client issues a RCPT command containing any valid NOTIFY and/or ORCPT parameters, a conforming SMTP server MUST return the same response it would return to the same RCPT command without those NOTIFY and/or ORCPT parameters. A conforming SMTP server MUST NOT refuse a RCPT command based on the presence or absence of any of these parameters. โœจ

However, if any of the associated esmtp-values are not valid, or if there's more than one of any of these parameters in a particular RCPT command, the server SHOULD issue the response "501 syntax error in parameter". ๐Ÿ”ฅ


5.2 Handling of messages received via SMTP ๐Ÿงš

This section describes how a conforming MTA should handle any messages it receives via SMTP.

NOTE: A DSN MUST NOT be returned to the sender for any message whose return address from the SMTP MAIL command was NULL ("<>"), even if the sender's address is available from other sources (e.g., the message header). However, the MTA that would otherwise issue a DSN SHOULD tell the local postmaster about delivery failures, through some appropriate mechanism that won't itself result in the generation of DSNs. ๐Ÿ™ˆ

DISCUSSION: RFC 1123, section 2.3.3 requires error notifications to be sent with a NULL return address ("reverse-path"). This creates a kind of plot twist when a message arrives with one or more nonfunctional recipient addresses plus a nonfunctional return address. When delivery to one of the recipient addresses fails, the MTA tries to send a nondelivery notification to the return address, and it sets the return address on that notification to NULL. If delivery of that notification then fails, the MTA attempting to deliver it sees a NULL return address. If that MTA didn't tell anyone what was going on, the original message would be silently lost. ๐Ÿ˜ฑ Also, a nonfunctional return address is often a sign of a configuration problem in the sender's MTA, so reporting the situation to the local postmaster can help speed up fixing those errors. ๐Ÿซถ


5.2.1 Relay of messages to other conforming SMTP servers ๐Ÿฆ‹

These rules govern how a conforming MTA behaves when it relays a message it received via SMTP to an SMTP server that supports the Delivery Status Notification service extension:

(a) Any ENVID parameter that was included in the MAIL command when the message was received MUST also appear on the MAIL command used to relay the message, with the same associated esmtp-value. If no ENVID parameter was included in the MAIL command when the message was received, the ENVID parameter MUST NOT be supplied when the message is relayed. ๐Ÿ’–

(b) Any RET parameter that was included in the MAIL command when the message was received MUST also appear on the MAIL command used to relay the message, with the same associated esmtp-value. If no RET parameter was included in the MAIL command when the message was received, the RET parameter MUST NOT be supplied when the message is relayed. ๐ŸŒˆ

(c) If the NOTIFY parameter was supplied for a recipient when the message was received, the RCPT command issued when the message is relayed MUST also contain the NOTIFY parameter along with its associated esmtp-value. If the NOTIFY parameter wasn't supplied for a recipient when the message was received, the NOTIFY parameter MUST NOT be supplied for that recipient when the message is relayed. ๐Ÿ‘‘

(d) If any ORCPT parameter was present in the RCPT command for a recipient when the message was received, an ORCPT parameter with the identical original-recipient-address MUST appear in the RCPT command issued for that recipient when relaying the message. (For example, the MTA therefore MUST NOT change the case of any alphabetic characters in an ORCPT parameter.) If no ORCPT parameter was present in the RCPT command when the message was received, an ORCPT parameter MAY be added to the RCPT command when the message is relayed. If an ORCPT parameter is added by the relaying MTA, it MUST contain the recipient address from the RCPT command used when the message was received by that MTA. ๐Ÿ“


5.2.2 Relay of messages to non-conforming SMTP servers ๐ŸŒธ

These rules govern how a conforming MTA (in the role of client) behaves when it relays a message it received via SMTP to an SMTP server that does not support the Delivery Status Notification service extension:

(a) ENVID, NOTIFY, RET, or ORCPT parameters MUST NOT be issued when relaying the message. ๐Ÿ™…โ€โ™€๏ธ

(b) If the NOTIFY parameter was supplied for a recipient, with an esmtp-value containing the keyword SUCCESS, and the SMTP server returns a success (2xx) reply-code in response to the RCPT command, the client MUST issue a "relayed" DSN for that recipient. ๐ŸŽ€

(c) If the NOTIFY parameter was supplied for a recipient with an esmtp-value containing the keyword FAILURE, and the SMTP server returns a permanent failure (5xx) reply-code in response to the RCPT command, the client MUST issue a "failed" DSN for that recipient. ๐Ÿ’€

(d) If the NOTIFY parameter was supplied for a recipient with an esmtp-value of NEVER, the client MUST NOT issue a DSN for that recipient, regardless of the reply-code the SMTP server returns. However, if the server returned a failure (5xx) reply-code, the client MAY inform the local postmaster of the delivery failure through an appropriate mechanism that won't itself result in the generation of DSNs. โœจ

When trying to relay a message to an SMTP server that doesn't support this extension, and NOTIFY=NEVER was specified for some of that message's recipients, a conforming SMTP client MAY relay the message for those recipients in a separate SMTP transaction, using an empty reverse-path in the MAIL command. This prevents DSNs from being issued for those recipients by MTAs that conform to [1]. ๐Ÿง 

(e) If a NOTIFY parameter wasn't supplied for a recipient, and the SMTP server returns a success (2xx) reply-code in response to a RCPT command, the client MUST NOT issue any DSN for that recipient. ๐Ÿซ 

(f) If a NOTIFY parameter wasn't supplied for a recipient, and the SMTP server returns a permanent failure (5xx) reply-code in response to a RCPT command, the client MUST issue a "failed" DSN for that recipient. ๐Ÿ˜ค


5.2.3 Local delivery of messages ๐Ÿ“ฌ

These rules govern how a conforming MTA behaves when it successfully delivers a message it received via SMTP to a local recipient's mailbox:

"Delivery" means that the message has been placed in the recipient's mailbox. For messages that are sent to a mailbox for later retrieval via IMAP [9], POP [10], or a similar message access protocol, "delivery" happens when the message is made available to the IMAP (POP, etc.) service, not when the recipient's user agent actually retrieves it. ๐Ÿ“ฅ

Similarly, for a recipient address that corresponds to a mailing list exploder, "delivery" happens when the message is made available to that list exploder, even though the list exploder might refuse to deliver that message to the list recipients. ๐Ÿซง

(a) If the NOTIFY parameter was supplied for that recipient, with an esmtp-value containing the SUCCESS keyword, the MTA MUST issue a "delivered" DSN for that recipient. ๐Ÿฅณ

(b) If the NOTIFY parameter was supplied for that recipient and did not contain the SUCCESS keyword, the MTA MUST NOT issue a DSN for that recipient. ๐Ÿ™Š

(c) If the NOTIFY parameter was not supplied for that recipient, the MTA MUST NOT issue a DSN. ๐Ÿ’…

5.2.4. Gatewaying a message into a foreign environment โœจ

okay so this one is about what a conforming MTA has to do when it takes a message that came in over SMTP and gateways it into a foreign (non-SMTP) environment ๐ŸŒˆ here's the vibe:

  • (a) if the foreign environment can send notifications under the conditions the NOTIFY parameter asked for, AND the conforming MTA can make sure any notification gets turned into a DSN and delivered back to the original sender, then the MTA SHOULD gateway the message into the foreign environment, requesting notification under the desired conditions, without issuing a DSN itself ๐Ÿ™…โ€โ™€๏ธ no double-dipping, bestie
  • (b) if a NOTIFY parameter came with the SUCCESS keyword, but the destination environment can't send back an appropriate notification on successful delivery, the MTA SHOULD issue a "relayed" DSN for that recipient ๐Ÿ“ฌ
  • (c) if a NOTIFY parameter had an esmtp-keyword of NEVER, a DSN MUST NOT be issued. if possible, the MTA SHOULD tell the destination environment not to send delivery notifications for that recipient ๐Ÿค
  • (d) if the NOTIFY parameter wasn't supplied for a particular recipient, the gateway SHOULD NOT issue a DSN. it SHOULD try to make sure the foreign mail environment provides appropriate notification if eventual delivery failure happens, and that no notification goes out on successful delivery ๐Ÿซถ
  • (e) when gatewaying into a foreign environment, the return-of-content conditions from any RET parameter are nonbinding ๐Ÿ“ but the MTA SHOULD still attempt to honor the request using whatever mechanisms exist in the foreign environment

5.2.5. Delays in delivery ๐Ÿข

this is the "why is it taking forever" section ๐Ÿ˜ญ if a conforming MTA gets a message over SMTP and is unable to deliver or relay it to one or more recipients for an extended length of time (the MTA decides how long that is), it MAY issue a "delayed" DSN for those recipients, subject to these conditions:

  • (a) if the NOTIFY parameter was supplied for a recipient and its value included the DELAY keyword, a "delayed" DSN MAY be issued.
  • (b) if the NOTIFY parameter was not supplied for a recipient, a "delayed" DSN MAY be issued.
  • (c) if the NOTIFY parameter was supplied and did not contain the DELAY keyword, a "delayed" DSN MUST NOT be issued.
NOTE: delay notifications are super common in present-day email ๐Ÿ“จ but a conforming MTA is never required to issue "delayed" DSNs. the DELAY keyword of the NOTIFY parameter exists so the SMTP client can specifically ask (by omitting the DELAY parameter) that "delayed" DSNs NOT be issued. main character energy ๐Ÿ’…

5.2.6. Failure of a conforming MTA to deliver a message ๐Ÿ’€

okay, this is the "it didn't work" section. these rules cover a conforming MTA that got a message over SMTP and can't deliver it to a recipient named in the SMTP transaction:

  • (a) if the NOTIFY parameter was supplied for the recipient with an esmtp-keyword containing the value FAILURE, a "failed" DSN MUST be issued by the MTA.
  • (b) if the NOTIFY parameter was supplied for the recipient but did not contain the value FAILURE, a DSN MUST NOT be issued for that recipient. however, the MTA MAY inform the local postmaster of the delivery failure via some appropriate mechanism which does not itself result in the generation of DSNs ๐Ÿ™ˆ
  • (c) if no NOTIFY parameter was supplied for the recipient, a "failed" DSN MUST be issued.
NOTE: some MTAs forward undeliverable messages to the local postmaster or a "dead letter" mailbox. that still counts as delivery failure, and it doesn't reduce the requirement to issue a "failed" DSN under the conditions defined elsewhere in this memo. if a DSN is issued for such a recipient, the Action value MUST be "failed" ๐Ÿ”ฅ

5.2.7. Forwarding, aliases, and mailing lists ๐Ÿ“ช

delivering to a local email address usually drops the message into the recipient's mailbox. but MTAs often let a local address be an "alias" or a "mailing list," so delivery gets forwarded to each (local or remote) recipient linked to it ๐Ÿฆ‹ users can also optionally "forward" their mail to one or more other addresses, and if that's turned on, the mail gets redistributed there instead of landing in their mailbox. iconic behavior, honestly โœจ

Following the example of [11] (section 5.3.6), this document defines the difference between an "alias" and a "mailing list" like this: when a message is forwarded to the addresses behind an "alias," the envelope return address (e.g., MAIL FROM) stays intact. but when it's forwarded to the addresses behind a "mailing list," the envelope return address gets changed to the list administrator's. that way, DSNs and other nondelivery reports from the list members go to the list administrator instead of the original sender ๐Ÿงš

The DSN processing for aliases and mailing lists goes like this:

5.2.7.1. mailing lists ๐Ÿ’Œ

when a message is delivered to a list submission address (aka placed in the list's incoming mailbox, or accepted by the process that redistributes it to the subscribers), that counts as final delivery for the original message. if the NOTIFY parameter for the list submission address contained the SUCCESS keyword, a "delivered" DSN MUST be returned to the sender of the original message.

NOTE: some mailing lists can reject submissions based on the message content, the sender's address, or some other criteria. the interface between a list like that and its MTA isn't well-defined, but it's really important that DSNs NOT be issued by both the MTA (to report successful delivery to the list) and the list (to report rejection with a "failure" DSN) ๐Ÿ™…โ€โ™€๏ธ

even if a "delivered" DSN was issued by the MTA, a mailing list that rejects a submission MAY tell the sender about the rejection using an ordinary message instead of a DSN.

Whenever a message is redistributed to a mailing list:

  • (a) the envelope return address is rewritten to point to the list maintainer. this address MAY be a process that recognizes DSNs and processes them automatically, but it MUST forward unrecognized messages to the human responsible for the list ๐Ÿ‘‘
  • (b) the ENVID, NOTIFY, RET, and ORCPT parameters that come with the redistributed message MUST NOT be derived from those of the original message.
  • (c) the NOTIFY and RET parameters MAY be specified by the local postmaster or the list administrator. if ORCPT parameters are supplied during redistribution to the list subscribers, they SHOULD contain the addresses of the list subscribers in the format the mailing list uses ๐Ÿ’–

5.2.7.2. single-recipient aliases ๐ŸŽ€

under normal circumstances, when a message arrives for an "alias" that has a single forwarding address, a DSN SHOULD NOT be issued. any ENVID, NOTIFY, RET, or ORCPT parameters SHOULD be propagated with the message as it gets redistributed to that forwarding address ๐ŸŒธ

5.2.7.3. multiple-recipient aliases ๐Ÿงฉ

an "alias" with multiple recipient addresses can be handled in any of these ways:

  • (a) any ENVID, NOTIFY, RET, or ORCPT parameters are NOT propagated when the message is relayed to any of the forwarding addresses. if the NOTIFY parameter for the alias contained the SUCCESS keyword, the MTA issues a "relayed" DSN. (in effect, the MTA treats the message as if it were being relayed into an environment that doesn't support DSNs ๐Ÿคทโ€โ™€๏ธ)
  • (b) any ENVID, NOTIFY, RET, or ORCPT parameters (or the equivalent requests if the message is gatewayed) are propagated to EXACTLY one of the forwarding addresses. no DSN is issued. (this is perfect when aliasing is used to forward a message to a "vacation" auto-responder program in addition to the local mailbox ๐Ÿ–๏ธ)
  • (c) any ENVID, RET, or ORCPT parameters are propagated to all forwarding addresses associated with that alias. the NOTIFY parameter is propagated to the forwarding addresses, except that any SUCCESS keyword is removed. if the original NOTIFY parameter for the alias contained the SUCCESS keyword, an "expanded" DSN is issued for the alias. if the NOTIFY parameter for the alias did not contain the SUCCESS keyword, no DSN is issued for the alias ๐ŸŒŸ

5.2.7.4. confidential forwarding addresses ๐Ÿคซ

if it's important to keep a recipient's forwarding address confidential, the forwarding can be treated as if it were a mailing list. a DSN will be issued, if appropriate, upon "delivery" to the recipient address the sender specified. when the message is forwarded, it gets a new envelope return address. any DSNs that result from delivery failure of the forwarded message will not be returned to the original sender, so the recipient's forwarding address stays hidden ๐Ÿงšโ€โ™€๏ธ๐Ÿ”’

5.2.8. DSNs describing delivery to multiple recipients ๐Ÿ“‹

a single DSN can describe attempts to deliver a message to multiple recipients of that message. if a DSN is issued for some recipients in an SMTP transaction and not for others, according to the rules above, the DSN SHOULD NOT contain information for recipients who wouldn't otherwise have gotten a DSN ๐Ÿซถ


5.3. Handling of messages from other sources ๐Ÿ“ฎ

for messages that originated from "local" users (whatever that means ๐Ÿ™„), the specs for how DSNs should be generated can be communicated to the MTA through any protocol agreed on between the sender's mail composer (user agent) and the MTA. the local MTA can then either relay the message or issue the appropriate delivery status notifications. however, if those requests are transmitted within the message itself (for example, in the message headers), the requests MUST be removed from the message before it is transmitted via SMTP ๐Ÿšซ

for messages gatewayed from non-SMTP sources and then relayed by SMTP, the gateway SHOULD, using the SMTP extensions described here, attempt to provide the delivery reporting conditions the source mail environment expects. if appropriate, any DSNs returned to the source environment SHOULD be translated into the format that environment expects ๐Ÿ’…

5.4 Implementation limits โœจ

Okay bestie, time for the size limits ๐Ÿ“ A conforming MTA MUST accept ESMTP parameters of at least these sizes:

  • (a) ENVID parameter: 100 characters.
  • (b) NOTIFY parameter: 28 characters.
  • (c) ORCPT parameter: 500 characters.
  • (d) RET parameter: 8 characters.

The max sizes for ENVID and ORCPT are meant to be big enough for "foreign" envelope identifiers and original recipient addresses ๐Ÿ’…. However, user agents that use SMTP as a message submission protocol SHOULD NOT generate ENVID parameters longer than 38 characters ๐Ÿ™ˆ

A conforming MTA MUST be able to accept SMTP command-lines at least 1036 characters long (530 characters for the ORCPT and NOTIFY parameters of the RCPT command, on top of the 512 characters required by [1]). If other SMTP extensions are supported by the MTA, the MTA MUST be able to accept a command-line large enough for each SMTP command and any combination of ESMTP parameters which may be used with that command ๐Ÿฆ‹


6. Format of delivery notifications ๐Ÿ“ฌ

Okay so the format of Delivery Status Notifications is defined in [3], which uses the framework defined in [5] ๐Ÿง  DSNs are to be returned to the sender of the original message, as outlined below.

6.1 SMTP Envelope to be used with Delivery Status Notifications

The DSN sender address (in the SMTP MAIL command) MUST be a null reverse-path (<>), as required by section 5.3.3 of [11] ๐Ÿ’Œ The DSN recipient address (in the RCPT command) is copied from the MAIL command that came with the message the DSN is being issued for. When transmitting a DSN via SMTP, the RET parameter MUST NOT be used. The NOTIFY parameter MAY be used, but its value MUST be NEVER. The ENVID parameter (with a newly generated envelope-id) and/or ORCPT parameter MAY be used โœจ

6.2 Contents of the DSN

A DSN is transmitted as a MIME message with a top-level content-type of multipart/report (as defined in [3]) ๐ŸŽ€

The multipart/report content-type can be used for any of several kinds of reports the mail system generates. When multipart/report is used to convey a DSN, the report-type parameter of the multipart/report content-type is "delivery-status" ๐Ÿ’–

As described in [5], the first component of a multipart/report content-type is a human-readable explanation of the report. For a DSN, the second component of the multipart/report is of content-type message/delivery-status (defined in [3]). The third component of the multipart/report consists of the original message or some portion of it. When the value of the RET parameter is FULL, the full message SHOULD be returned for any DSN which conveys notification of delivery failure. (However, if the length of the message is greater than some implementation-specified length, the MTA MAY return only the headers even if the RET parameter specified FULL.) If a DSN contains no notifications of delivery failure, the MTA SHOULD return only the headers ๐Ÿ™ˆ

The third component must have an appropriate content-type label. Issues concerning selection of the content-type are discussed in [5] ๐Ÿซถ

6.3 Message/delivery-status fields

The message/delivery-status content-type defines a number of fields, with general specifications for their contents. The following requirements for any DSNs generated in response to a message received by the SMTP protocol by a conforming SMTP server are in addition to the requirements defined in [3] for the message/delivery-status type ๐Ÿ“‹

When generating a DSN for a message which was received via the SMTP protocol, a conforming MTA will generate the following fields of the message/delivery-status body part:

  • (a) if an ENVID parameter was present on the MAIL command, an Original-Envelope-ID field MUST be supplied, and the value associated with the ENVID parameter must appear in that field. If the message was received via SMTP with no ENVID parameter, the Original-Envelope-ID field MUST NOT be supplied. Since the ENVID parameter is encoded as xtext, but the Original-Envelope-ID header is not encoded as xtext, the MTA must decode the xtext encoding when copying the ENVID value to the Original-Envelope-ID field ๐Ÿ”
  • (b) The Reporting-MTA field MUST be supplied. If the Reporting MTA can determine its fully-qualified Internet domain name, the MTA-name-type subfield MUST be "dns", and the field MUST contain the fully-qualified domain name of the Reporting MTA. If the fully-qualified Internet domain name of the Reporting MTA is not known (for example, for an SMTP server which is not directly connected to the Internet), the Reporting-MTA field may contain any string identifying the MTA; however, in this case the MTA-name-type subfield MUST NOT be "dns". A MTA-name-type subfield value of "x-local-hostname" is suggested ๐Ÿ 
  • (c) Other per-message fields as defined in [3] MAY be supplied as appropriate. ๐ŸŒธ
  • (d) If the ORCPT parameter was provided for this recipient, the Original-Recipient field MUST be supplied, with its value taken from the ORCPT parameter. If no ORCPT parameter was provided for this recipient, the Original-Recipient field MUST NOT appear. ๐Ÿ“
  • (e) The Final-Recipient field MUST be supplied. It MUST contain the recipient address from the message envelope. If the message was received via SMTP, the address-type will be "rfc822" ๐Ÿ’œ
  • (f) The Action field MUST be supplied. ๐ŸŽฌ
  • (g) The Status field MUST be supplied, using a status-code from [6]. If there is no specific code which suitably describes a delivery failure, either 4.0.0 (temporary failure), or 5.0.0 (permanent failure) MUST be used ๐Ÿšฆ
  • (h) For DSNs resulting from attempts to relay a message to one or more recipients via SMTP, the Remote-MTA field MUST be supplied for each of those recipients. The mta-name-type subfields of those Remote-MTA fields will be "dns" ๐Ÿ›ฐ๏ธ
  • (i) For DSNs resulting from attempts to relay a message to one or more recipients via SMTP, the Diagnostic-Code MUST be supplied for each of those recipients. The diagnostic-type subfield will be "smtp". See section 9.2 of this document for a description of the "smtp" diagnostic-code ๐Ÿฉบ
  • (j) For DSNs resulting from attempts to relay a message to one or more recipients via SMTP, an SMTP-Remote-Recipient extension field MAY be supplied for each recipient, which contains the address of that recipient which was presented to the remote SMTP server ๐Ÿงš
  • (k) Other per-recipient fields defined in [3] MAY appear, as appropriate. ๐ŸŒˆ

7. Acknowledgments ๐Ÿซถ

The author wishes to thank Eric Allman, Harald Alvestrand, Jim Conklin, Bryan Costales, Peter Cowen, Dave Crocker, Roger Fajman, Ned Freed, Marko Kaittola, Steve Kille, John Klensin, Anastasios Kotsikonas, John Gardiner Myers, Julian Onions, Jacob Palme, Marshall Rose, Greg Vaudreuil, and Klaus Weide for their suggestions for improvement of this document ๐Ÿ‘‘

8. Security Considerations ๐Ÿ”ฅ

The SMTP extension described in this document does not change the fundamental nature of the SMTP service, and hence does not create any new security exposures in and of itself. It necessarily adds complexity to implementations, however, and with added complexity comes an increased risk of implementation errors ๐Ÿ˜ญโš ๏ธ

Previous ad-hoc delivery notification mechanisms sometimes produced a storm of receipts due to unanticipated interactions with mailing list expansion software. In this specification, notification of successful delivery is carefully designed so, if properly implemented, it cannot interact with a list expander in this way ๐Ÿ’€

The security considerations section in [5] describes security issues associated with multipart/report objects in general, and the security considerations section in [3] describes security issues with DSNs in particular ๐Ÿ›ก๏ธ

9. Appendix - Type-Name Definitions ๐Ÿงš

The following type names are defined for use in DSN fields generated by conforming SMTP-based MTAs ๐Ÿฆ‹

9.1 "rfc822" address-type

The "rfc822" address-type is to be used when reporting Internet electronic mail addresses in the Original-Recipient and Final-Recipient DSN fields ๐Ÿ’Œ

  • (a) address-type name: rfc822
  • (b) syntax for mailbox addresses

RFC822 mailbox addresses are generally expected to be of the form:

[route] addr-spec

where "route" and "addr-spec" are defined in [2], and the "domain" portions of both "route" and "addr-spec" are fully-qualified domain names that are registered in the DNS. However, an MTA MUST NOT modify an address obtained from the message envelope to force it to conform to syntax rules ๐Ÿšซ

  • (c) If addresses of this type are not composed entirely of graphic characters from the US-ASCII repertoire, a specification for how they are to be encoded as graphic US-ASCII characters in a DSN Original-Recipient or Final-Recipient DSN field.

RFC822 addresses consist entirely of graphic characters from the US-ASCII repertoire, so no translation is necessary โœ…

9.2 "smtp" diagnostic-type

The "smtp" diagnostic-type is to be used when reporting SMTP reply-codes in Diagnostic-Code DSN fields ๐Ÿฉต

  • (a) diagnostic-type name: SMTP
  • (b) A description of the syntax to be used for expressing diagnostic codes of this type as graphic characters from the US-ASCII repertoire.

An SMTP diagnostic-code is of the form:

*( 3*DIGIT "-" *text ) 3*DIGIT SPACE *text

For a single-line SMTP reply to an SMTP command, the diagnostic-code SHOULD be an exact transcription of the reply. For multi-line SMTP replies, it is necessary to insert a SPACE before each line after the first. For example, an SMTP reply of:

550-mailbox unavailable
550 user has moved with no forwarding address

could appear as follows in a Diagnostic-Code DSN field:

Diagnostic-Code: smtp ; 550-mailbox unavailable
 550 user has moved with no forwarding address
  • (c) A list of valid diagnostic codes of this type and the meaning of each code.

SMTP reply-codes are currently defined in [1] and [11]. Additional codes may be defined by other RFCs ๐ŸŒŸ

9.3. "dns" MTA-name-type ๐ŸŒ

okay so the "dns" MTA-name-type is the one that should be used in the Reporting-MTA field ๐Ÿ’… An MTA-name of type "dns" is a fully-qualified domain name. The name must be registered in the DNS, and the address Postmaster@{mta-name} must be valid. no cap, it's giving very "check your DNS before you show up" energy ๐Ÿงš

  • (a) MTA-name-type name: dns
  • (b) A description of the syntax of MTA names of this type, using BNF, regular expressions, ASN.1, or other non-ambiguous language.

MTA names of type "dns" SHOULD be valid Internet domain names ๐ŸŽ€ If such domain names are not available, a domain-literal containing the internet protocol address is acceptable. Such domain names generally conform to the following syntax:

                domain = real-domain / domain-literal

                real-domain = sub-domain *("." sub-domain)

                sub-domain = atom

                domain-literal = "[" 1*3DIGIT 3("." 1*3DIGIT) "]"

where "atom" and "DIGIT" are defined in [2] ๐Ÿค“

  • (c) If MTA names of this type do not consist entirely of graphic characters from the US-ASCII repertoire, a specification for how an MTA name of this type should be expressed as a sequence of graphic US-ASCII characters.

MTA names of type "dns" consist entirely of graphic US-ASCII characters, so no translation is needed โœจ we love a rule that just works ๐ŸŒธ


10. Appendix - Example ๐Ÿฆ‹

okay this is the main character moment ๐Ÿ‘‘ This example traces the flow of a single message addressed to multiple recipients. The message is sent by Alice@Example.ORG to Bob@Example.COM, Carol@Ivory.EDU, Dana@Ivory.EDU, Eric@Bombs.AF.MIL, Fred@Bombs.AF.MIL, and George@Tax-ME.GOV, with a variety of per-recipient options. The message is successfully delivered to Bob, Dana (via a gateway), Eric, and Fred. Delivery fails for Carol and George ๐Ÿ˜ญ

NOTE: Formatting rules for RFCs require that no line be longer than 72 characters. Therefore, in the following examples, some SMTP commands longer than 72 characters are printed on two lines, with the first line ending in "". In an actual SMTP transaction, such a command would be sent as a single line (i.e., with no embedded CRLFs), and without the "" character that appears in these examples.

10.1. Submission ๐Ÿ“ฎ

Alice's user agent sends the message to the SMTP server at Example.ORG. Note that while this example uses SMTP as a mail submission protocol, other protocols could also be used ๐Ÿ’–

<<< 220 Example.ORG SMTP server here
>>> EHLO Example.ORG
<<< 250-Example.ORG
<<< 250-DSN
<<< 250-EXPN
<<< 250 SIZE
>>> MAIL FROM:<Alice@Example.ORG> RET=HDRS ENVID=QQ314159
<<< 250 <Alice@Example.ORG> sender ok
>>> RCPT TO:<Bob@Example.COM> NOTIFY=SUCCESS \
    ORCPT=rfc822;Bob@Example.COM
<<< 250 <Bob@Example.COM> recipient ok
>>> RCPT TO:<Carol@Ivory.EDU> NOTIFY=FAILURE \
    ORCPT=rfc822;Carol@Ivory.EDU
<<< 250 <Carol@Ivory.EDU> recipient ok
>>> RCPT TO:<Dana@Ivory.EDU> NOTIFY=SUCCESS,FAILURE \
    ORCPT=rfc822;Dana@Ivory.EDU
<<< 250 <Dana@Ivory.EDU> recipient ok
>>> RCPT TO:<Eric@Bombs.AF.MIL> NOTIFY=FAILURE \
    ORCPT=rfc822;Eric@Bombs.AF.MIL
<<< 250 <Eric@Bombs.AF.MIL> recipient ok
>>> RCPT TO:<Fred@Bombs.AF.MIL> NOTIFY=NEVER
<<< 250 <Fred@Bombs.AF.MIL> recipient ok
>>> RCPT TO:<George@Tax-ME.GOV> NOTIFY=FAILURE \
    ORCPT=rfc822;George@Tax-ME.GOV
<<< 250 <George@Tax-ME.GOV> recipient ok
>>> DATA
<<< 354 okay, send message
>>> (message goes here)
>>> .
<<< 250 message accepted
>>> QUIT
<<< 221 goodbye

10.2. Relay to Example.COM ๐Ÿ”

The SMTP at Example.ORG then relays the message to Example.COM. (For the purpose of this example, mail.Example.COM is the primary mail exchanger for Example.COM.) ๐Ÿซถ

<<< 220 mail.Example.COM says hello
>>> EHLO Example.ORG
<<< 250-mail.Example.COM
<<< 250 DSN
>>> MAIL FROM:<Alice@Example.ORG> RET=HDRS ENVID=QQ314159
<<< 250 sender okay
>>> RCPT TO:<Bob@Example.COM> NOTIFY=SUCCESS \
    ORCPT=rfc822;Bob@Example.COM
<<< 250 recipient okay
>>> DATA
<<< 354 send message
>>> (message goes here)
>>> .
<<< 250 message received
>>> QUIT
<<< 221 bcnu

10.3. Relay to Ivory.EDU ๐ŸŒˆ

The SMTP at Example.ORG relays the message to Ivory.EDU, which (as it happens) is a gateway to a LAN-based mail system that accepts SMTP mail and supports the DSN extension ๐Ÿงƒ

<<< 220 Ivory.EDU gateway to FooMail(tm) here
>>> EHLO Example.ORG
<<< 250-Ivory.EDU
<<< 250 DSN
>>> MAIL FROM:<Alice@Example.ORG> RET=HDRS ENVID=QQ314159
<<< 250 ok
>>> RCPT TO:<Carol@Ivory.EDU> NOTIFY=FAILURE \
    ORCPT=rfc822;Carol@Ivory.EDU
<<< 550 error - no such recipient
>>> RCPT TO:<Dana@Ivory.EDU> NOTIFY=SUCCESS,FAILURE \
    ORCPT=rfc822;Dana@Ivory.EDU
<<< 250 recipient ok
>>> DATA
<<< 354 send message, end with '.'
>>> (message goes here)
>>> .
<<< 250 message received
>>> QUIT
<<< 221 bye

Note that since the Ivory.EDU refused to accept mail for Carol@Ivory.EDU, and the sender specified NOTIFY=FAILURE, the sender-SMTP (in this case Example.ORG) must generate a DSN ๐Ÿ™ˆ that's the drama right there, Carol gets a failure notice ๐Ÿ’€

10.4. Relay to Bombs.AF.MIL ๐ŸŽ–๏ธ

The SMTP at Example.ORG relays the message to Bombs.AF.MIL, which does not support the SMTP extension. Because the sender specified NOTIFY=NEVER for recipient Fred@Bombs.AF.MIL, the SMTP at Example.ORG chooses to send the message for that recipient in a separate transaction with a reverse-path of <> โœจ lowkey so smart, Fred gets his own little session ๐Ÿฆ‹

<<< 220-Bombs.AF.MIL reporting for duty.
<<< 220 Electronic mail is to be used for official business only.
>>> EHLO Example.ORG
<<< 502 command not implemented
>>> RSET
<<< 250 reset
>>> HELO Example.ORG
<<< 250 Bombs.AF.MIL
>>> MAIL FROM:<Alice@Example.ORG>
<<< 250 ok
>>> RCPT TO:<Eric@Bombs.AF.MIL>
<<< 250 ok
>>> DATA
<<< 354 send message
>>> (message goes here)
>>> .
<<< 250 message accepted
>>> MAIL FROM:<>
<<< 250 ok
>>> RCPT TO:<Fred@Bombs.AF.MIL>
<<< 250 ok
>>> DATA
<<< 354 send message
>>> (message goes here)
>>> .
<<< 250 message accepted
>>> QUIT
<<< 221 Bombs.AF.MIL closing connection

10.5. Forward from George@Tax-ME.GOV to Sam@Boondoggle.GOV ๐Ÿ•ต๏ธ

The SMTP at Example.ORG relays the message to Tax-ME.GOV. (this step is not shown). MTA Tax-ME.GOV then forwards the message to Sam@Boondoggle.GOV (shown below). Both Tax-ME.GOV and Example.ORG support the SMTP DSN extension. Note that RET, ENVID, and ORCPT all retain their original values ๐Ÿ“ the forwarding glow-up is real ๐Ÿ’…

<<< 220 BoonDoggle.GOV says hello
>>> EHLO Example.ORG
<<< 250-mail.Example.COM
<<< 250 DSN
>>> MAIL FROM:<Alice@Example.ORG> RET=HDRS ENVID=QQ314159
<<< 250 sender okay
>>> RCPT TO:<Sam@Boondoggle.GOV> NOTIFY=SUCCESS \
    ORCPT=rfc822;George@Tax-ME.GOV
<<< 250 recipient okay
>>> DATA
<<< 354 send message
>>> (message goes here)
>>> .
<<< 250 message received
>>> QUIT
<<< 221 bcnu

10.6. "Delivered" DSN for Bob@Example.COM ๐ŸŽ‰

MTA mail.Example.COM successfully delivers the message to Bob@Example.COM. Because the sender specified NOTIFY=SUCCESS, mail.Example.COM issues the following DSN, and sends it to Alice@Example.ORG ๐Ÿฅน bob got it, we're so back ๐Ÿ”ฅ

To: Alice@Example.ORG
From: postmaster@mail.Example.COM
Subject: Delivery Notification (success) for Bob@Example.COM
Content-Type: multipart/report; report-type=delivery-status;
    boundary=abcde
MIME-Version: 1.0

--abcde
Content-type: text/plain; charset=us-ascii

Your message (id QQ314159) was successfully delivered to
Bob@Example.COM.

--abcde
Content-type: message/delivery-status

Reporting-MTA: dns; mail.Example.COM
Original-Envelope-ID: QQ314159

Original-Recipient: rfc822;Bob@Example.COM
Final-Recipient: rfc822;Bob@Example.COM
Action: delivered
Status: 2.0.0

--abcde
Content-type: message/rfc822

(headers of returned message go here)

--abcde--

10.7. Failed DSN for Carol@Ivory.EDU ๐Ÿฅ€

Because delivery to Carol failed and the sender specified NOTIFY=FAILURE for Carol@Ivory.EDU, MTA Example.ORG (the SMTP client to which the failure was reported via SMTP) issues the following DSN ๐Ÿ’” poor Carol, but at least Alice knows what happened ๐Ÿซถ

To: Alice@Example.ORG
From: postmaster@Example.ORG
Subject: Delivery Notification (failure) for Carol@Ivory.EDU
Content-Type: multipart/report; report-type=delivery-status;
              boundary=bcdef
MIME-Version: 1.0

--bcdef
Content-type: text/plain; charset=us-ascii

Your message (id QQ314159) could not be delivered to
Carol@Ivory.EDU.

A transcript of the session follows:

(while talking to Ivory.EDU)
>>> RCPT TO:<Carol@Ivory.EDU> NOTIFY=FAILURE
<<< 550 error - no such recipient

--bcdef
Content-type: message/delivery-status

Reporting-MTA: dns; Example.ORG
Original-Envelope-ID: QQ314159

Original-Recipient: rfc822;Carol@Ivory.EDU
Final-Recipient: rfc822;Carol@Ivory.EDU
SMTP-Remote-Recipient: Carol@Ivory.EDU
Diagnostic-Code: smtp; 550 error - no such recipient
Action: failed
Status: 5.0.0

--bcdef
Content-type: message/rfc822

(headers of returned message go here)

--bcdef--

10.8. Relayed DSN For Dana@Ivory.EDU ๐ŸŒท

Although the mail gateway Ivory.EDU supports the DSN SMTP extension, the LAN mail system attached to its other side does not generate positive delivery confirmations. So Ivory.EDU issues a "relayed" DSN ๐Ÿ“จ it's giving "on its way, no receipt yet" vibes ๐Ÿงšโ€โ™€๏ธ

To: Alice@Example.ORG
From: postmaster@Ivory.EDU
Subject: mail relayed for Dana@Ivory.EDU
Content-Type: multipart/report; report-type=delivery-status;
    boundary=cdefg
MIME-Version: 1.0

--cdefg
Content-type: text/plain; charset=us-ascii

Your message (addressed to Dana@Ivory.EDU) was successfully
relayed to:

ymail!Dana

by the FooMail gateway at Ivory.EDU.

Unfortunately, the remote mail system does not support
confirmation of actual delivery. Unless delivery to ymail!Dana
fails, this will be the only Delivery Status Notification sent.

--cdefg
Content-type: message/delivery-status

Reporting-MTA: dns; Ivory.EDU
Original-Envelope-ID: QQ314159

Original-Recipient: rfc822;Dana@Ivory.EDU
Final-Recipient: rfc822;Dana@Ivory.EDU
Action: relayed
Status: 2.0.0

--cdefg
Content-type: message/rfc822

(headers of returned message go here)

--cdefg--

10.9 ๐Ÿฆ‹ Failure notification for Sam@Boondoggle.GOV

okay so the message meant for George@Tax-ME.GOV got forwarded to Sam@Boondoggle.GOV, but the MTA for Boondoggle.GOV couldn't deliver it because Sam's mailbox was out of disk space ๐Ÿ˜ญ. After trying for several days, Boondoggle.GOV sent back this DSN:

To: Alice@Example.ORG
From: Postmaster@Boondoggle.GOV
Subject: Delivery failure for Sam@Boondoggle.GOV
Content-Type: multipart/report; report-type=delivery-status;
              boundary=defgh
MIME-Version: 1.0

--defgh
Your message, originally addressed to George@Tax-ME.GOV, and
forwarded from there to Sam@Boondoggle.GOV could not be delivered,
for the following reason:

write error to mailbox, disk quota exceeded

--defgh
Content-type: message/delivery-status

Reporting-MTA: Boondoggle.GOV
Original-Envelope-ID: QQ314159

Original-Recipient: rfc822;George@Tax-ME.GOV
Final-Recipient: rfc822;Sam@Boondoggle.GOV
Action: failed
Status: 4.2.2 (disk quota exceeded)

--defgh
Content-type: message/rfc822

(headers of returned message go here)

--defgh--

11. Appendix - Changes since RFC 1891 โœจ

Here's the tea on what changed since RFC 1891 ๐Ÿ“

  • updated the author's address ๐Ÿ’Œ
  • in the examples, Pure-Heart.ORG and Big-Bucks.COM got swapped out for Example.ORG and Example.COM, respectively. Pure-Heart.ORG and Big-Bucks.COM have since been registered by somebody else, so they're off the menu ๐Ÿ™ˆ
  • clarified that the ENVID and ORCPT parameters must consist entirely of US-ASCII characters before they get encoded as xtext ๐Ÿงš
  • a Security Considerations section was added ๐Ÿ”ฅ๐Ÿ”

12. References ๐Ÿ“š

12.1 Normative References

  • [1] Postel, J., "Simple Mail Transfer Protocol", STD 10, RFC 821, August 1982.
  • [2] Crocker, D., "Standard for the format of ARPA Internet Text Messages", STD 11, RFC 822, August 1982.
  • [3] Moore, K., and G. Vaudreuil, "An Extensible Message Format for Delivery Status Notifications", RFC 3464, January 2003.
  • [4] Coded Character Set - 7-Bit American Standard Code for Information Interchange, ANSI X3.4-1986.
  • [5] Vaudreuil, G., "The Multipart/Report Content Type for the Reporting of Mail System Administrative Messages", RFC 3462, January 2003.
  • [6] Vaudreuil, G., "Enhanced Mail System Status Codes", RFC 3463, January 2003.
  • [7] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997.

12.2 Informative References ๐Ÿง 

  • [8] Westine, A. and J. Postel, "Problems with the Maintenance of Large Mailing Lists.", RFC 1211, March 1991.
  • [9] Crispin, M., "Internet Message Access Protocol - Version 4rev1", RFC 2060, December 1996.
  • [10] Myers, J. and M. Rose, "Post Office Protocol - Version 3", STD 53, RFC 1939, May 1996.
  • [11] Braden, R., Ed., "Requirements for Internet Hosts - Application and Support", STD 3, RFC 1123, October 1989.

13. Author's Address ๐Ÿ’–

Keith Moore
University of Tennessee
1122 Volunteer Blvd, Suite 203
Knoxville, TN 37996-3450
USA

EMail: moore@cs.utk.edu

Copyright (C) The Internet Society (2003). All Rights Reserved.

This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to the Internet Society or other Internet organizations, except as needed for the purpose of developing Internet standards in which case the procedures for copyrights defined in the Internet Standards process must be followed, or as required to translate it into languages other than English.

The limited permissions granted above are perpetual and will not be revoked by the Internet Society or its successors or assigns.

This document and the information contained herein is provided on an "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.

Acknowledgement ๐Ÿซถ

Funding for the RFC Editor function is currently provided by the Internet Society. ๐Ÿ’…

๐Ÿ“ฆ where this page comes from