RFC 2034 PROPOSED STANDARD EMAIL · SMTP · ERROR CODES

SMTP Enhanced Errors: SMTP Service Extension for Returning Enhanced Error Codes

Lets an SMTP server say exactly why a delivery worked or failed, using codes that software can read.

On rfc-editor.org ↗
PUBLISHED
October 1996
AUTHORS
N. Freed
ORG
Innosoft
STREAM
Legacy
EXTENSION NAME
Enhanced-Status-Codes
EHLO KEYWORD
ENHANCEDSTATUSCODES
REPLIES THAT CARRY A CODE
2xx, 4xx and 5xx
REPLIES THAT DO NOT
The greeting, and the replies to HELO or EHLO
CODE SHAPE
class.subject.detail
SERVER PORT IN THE EXAMPLE
25
DOI
10.17487/RFC2034

RFC text

Contents
Original text · RFC Editor View on rfc-editor.org ↗
Network Working Group                                       N. Freed
Request for Comments: RFC 2034                              Innosoft
Category: Standards Track                               October 1996


                       SMTP Service Extension for
                     Returning Enhanced Error Codes

Status of this Memo

   This document specifies an Internet standards track protocol for the
   Internet community, and requests discussion and suggestions for
   improvements.  Please refer to the current edition of the "Internet
   Official Protocol Standards" (STD 1) for the standardization state
   and status of this protocol.  Distribution of this memo is unlimited.

1.  Abstract

   This memo defines an extension to the SMTP service [RFC-821, RFC-
   1869] whereby an SMTP server augments its responses with the enhanced
   mail system status codes defined in RFC 1893.  These codes can then
   be used to provide more informative explanations of error conditions,
   especially in the context of the delivery status notifications format
   defined in RFC 1894.

2.  Introduction

   Although SMTP is widely and robustly deployed, various extensions
   have been requested by parts of the Internet community. In
   particular, in the modern, international, and multilingual Internet a
   need exists to assign codes to specific error conditions that can be
   translated into different languages. RFC 1893 defines such a set of
   status codes and RFC 1894 defines a mechanism to send such coded
   material to users. However, in many cases the agent creating the RFC
   1894 delivery status notification is doing so in response to errors
   it received from a remote SMTP server.

   As such, remote servers need a mechanism for embedding enhanced
   status codes in their responses as well as a way to indicate to a
   client when they are in fact doing this. This memo uses the SMTP
   extension mechanism described in RFC 1869 to define such a mechanism.

3.  Framework for the Enhanced Error Statuses Extension

   The enhanced error statuses transport extension is laid out as
   follows:

   (1)   the name of the SMTP service extension defined here is
         Enhanced-Status-Codes;

   (2)   the EHLO keyword value associated with the extension is
         ENHANCEDSTATUSCODES;

   (3)   no parameter is used with the ENHANCEDSTATUSCODES EHLO
         keyword;

   (4)   the text part of all 2xx, 4xx, and 5xx SMTP responses
         other than the initial greeting and any response to
         HELO or EHLO are prefaced with a status code as defined
         in RFC 1893. This status code is always followed by one
         or more spaces.

   (5)   no additional SMTP verbs are defined by this extension;
         and,

   (6)   the next section specifies how support for the
         extension affects the behavior of a server and client
         SMTP.

4.  The Enhanced-Status-Codes service extension

   Servers supporting the Enhanced-Status-Codes extension must preface
   the text part of almost all response lines with a status code. As in
   RFC 1893, the syntax of these status codes is given by the ABNF:

        status-code ::= class "." subject "." detail
        class       ::= "2" / "4" / "5"
        subject     ::= 1*3digit
        detail      ::= 1*3digit

   These codes must appear in all 2xx, 4xx, and 5xx response lines other
   than initial greeting and any response to HELO or EHLO. Note that 3xx
   responses are NOT included in this list.

   All status codes returned by the server must agree with the primary
   response code, that is, a 2xx response must incorporate a 2.X.X code,
   a 4xx response must incorporate a 4.X.X code, and a 5xx response must
   incorporate a 5.X.X code.

   When responses are continued across multiple lines the same status
   code must appear at the beginning of the text in each line of the
   response.

   Servers supporting this extension must attach enhanced status codes
   to their responses regardless of whether or not EHLO is employed by
   the client.

5.  Status Codes and Negotiation

   This specification does not provide a means for clients to request
   that status codes be returned or that they not be returned; a
   compliant server includes these codes in the responses it sends
   regardless of whether or not the client expects them.  This is
   somewhat different from most other SMTP extensions, where generally
   speaking a client must specifically make a request before the
   extended server behaves any differently than an unextended server.
   The omission of client negotiation in this case is entirely
   intentional: Given the generally poor state of SMTP server error code
   implementation it is felt that any step taken towards more
   comprehensible error codes is something that all clients, extended or
   not, should benefit from.

   IMPORTANT NOTE:  The use of this approach in this extension should be
   seen as a very special case.  It MUST NOT be taken as a license for
   future SMTP extensions to dramatically change the nature of SMTP
   client-server interaction without proper announcement from the server
   and a corresponding enabling command from the client.

6.  Usage Example

   The following dialogue illustrates the use of enhanced status codes
   by a server:

   S: <wait for connection on TCP port 25>
   C: <open connection to server>
   S: 220 dbc.mtview.ca.us SMTP service ready
   C: EHLO ymir.claremont.edu
   S: 250-dbc.mtview.ca.us says hello
   S: 250 ENHANCEDSTATUSCODES
   C: MAIL FROM:<ned@ymir.claremont.edu>
   S: 250 2.1.0 Originator <ned@ymir.claremont.edu> ok
   C: RCPT TO:<mrose@dbc.mtview.ca.us>
   S: 250 2.1.5 Recipient <mrose@dbc.mtview.ca.us> ok
   C: RCPT TO:<nosuchuser@dbc.mtview.ca.us>
   S: 550 5.1.1 Mailbox "nosuchuser" does not exist
   C: RCPT TO:<remoteuser@isi.edu>
   S: 551-5.7.1 Forwarding to remote hosts disabled
   S: 551 5.7.1 Select another host to act as your forwarder
   C: DATA
   S: 354 Send message, ending in CRLF.CRLF.
    ...
   C: .
   S: 250 2.6.0 Message accepted
   C: QUIT
   S: 221 2.0.0 Goodbye

   The client that receives these responses might then send a
   nondelivery notification of the general form:

      Date: Mon, 11 Mar 1996 09:21:47 -0400
      From: Mail Delivery Subsystem <mailer-daemon@ymir.claremont.edu>
      Subject: Returned mail
      To: <ned@ymir.claremont.edu>
      MIME-Version: 1.0
      Content-Type: multipart/report; report-type=delivery-status;
            boundary="JAA13167.773673707/YMIR.CLAREMONT.EDU"

      --JAA13167.773673707/YMIR.CLAREMONT.EDU
      content-type: text/plain; charset=us-ascii

         ----- Mail was successfully relayed to
               the following addresses -----

      <mrose@dbc.mtview.ca.us>

         ----- The following addresses had delivery problems -----
      <nosuchuser@dbc.mtview.ca.us>
        (Mailbox "nosuchuser" does not exist)
      <remoteuser@isi.edu>
        (Forwarding to remote hosts disabled)

      --JAA13167.773673707/YMIR.CLAREMONT.EDU
      content-type: message/delivery-status

      Reporting-MTA: dns; ymir.claremont.edu

      Original-Recipient: rfc822;mrose@dbc.mtview.ca.us
      Final-Recipient: rfc822;mrose@dbc.mtview.ca.us
      Action: relayed
      Status: 2.1.5 (Destination address valid)
      Diagnostic-Code: smtp;
       250 Recipient <mrose@dbc.mtview.ca.us> ok
      Remote-MTA: dns; dbc.mtview.ca.us
      Original-Recipient: rfc822;nosuchuser@dbc.mtview.ca.us
      Final-Recipient: rfc822;nosuchuser@dbc.mtview.ca.us
      Action: failed
      Status: 5.1.1 (Bad destination mailbox address)
      Diagnostic-Code: smtp;
       550 Mailbox "nosuchuser" does not exist
      Remote-MTA: dns; dbc.mtview.ca.us

      Original-Recipient: rfc822;remoteuser@isi.edu
      Final-Recipient: rfc822;remoteuser@isi.edu
      Action: failed
      Status: 5.7.1 (Delivery not authorized, message refused)
      Diagnostic-Code: smtp;
        551 Forwarding to remote hosts disabled
        Select another host to act as your forwarder
      Remote-MTA: dns; dbc.mtview.ca.us

      --JAA13167.773673707/YMIR.CLAREMONT.EDU
      content-type: message/rfc822

      [original message goes here]
      --JAA13167.773673707/YMIR.CLAREMONT.EDU--

   Note that in order to reduce clutter the reporting MTA has omitted
   enhanced status code information from the diagnostic-code fields it
   has generated.

7.  Security Considerations

   Additional detail in server responses axiomatically provides
   additional information about the server.  It is conceivable that
   additional information of this sort may be of assistance in
   circumventing server security.  The advantages of provides additional
   information must always be weighed against the security implications
   of doing so.

8.  References

   [RFC-821]
        Postel, J., "Simple Mail Transfer Protocol", RFC 821,
        August, 1982.  (August, 1982).

   [RFC-1869]
        Rose, M., Stefferud, E., Crocker, C., Klensin, J., Freed,
        N., "SMTP Service Extensions", RFC 1869, November, 1995.

   [RFC-1893]
        Vaudreuil, G., "Enhanced Mail System Status Codes", RFC
        1893, January, 1996.

   [RFC-1894]
        Moore, K., Vaudreuil, G., "An Extensible Message Format
        for Delivery Status Notifications", RFC 1894, January,
        1996.

9.  Author Address

   Ned Freed
   Innosoft International, Inc.
   1050 East Garvey Avenue South
   West Covina, CA 91790
   USA
    tel: +1 818 919 3600           fax: +1 818 919 3614
    email: ned@innosoft.com

ISO Plain Language

On this page
PROBLEMSMTP replies carry a three-digit code such as 550 that says only that something went wrong. The sender then has to guess the reason, and cannot pass a machine-readable reason on to the person who sent the mail.
MECHANISMThe Enhanced-Status-Codes extension makes a server prefix the text of its 2xx, 4xx and 5xx replies with a status code of the form class.subject.detail, taken from RFC 1893, and announces the capability with the EHLO keyword ENHANCEDSTATUSCODES.
WHY IT MATTERSClients can report a precise reason for a failure in a delivery status notification, and the codes can be translated into different languages. The extension is applied whether or not the client asks for it.

§2Why Servers Need Better Error Codes

SMTP is widely and robustly deployed, but parts of the Internet community have asked for extensions. In a modern, international and multilingual Internet there is a need to assign codes to specific error conditions that can be translated into different languages. RFC 1893 defines such a set of status codes, and RFC 1894 defines a mechanism for sending coded material to users.

In many cases the agent that creates the RFC 1894 delivery status notification does so in response to errors it received from a remote SMTP server. Remote servers therefore need a mechanism for embedding enhanced status codes in their responses, and a way to indicate to a client when they are doing this. This document uses the SMTP extension mechanism described in RFC 1869 to define such a mechanism.

When mail bounces, the software that reports it usually only knows the reply code from the far end. These longer codes say what actually went wrong, in a form a computer can pass along.

§3The Extension Framework

The enhanced error statuses transport extension is laid out as follows. The name of the SMTP service extension is Enhanced-Status-Codes. The EHLO keyword value associated with the extension is ENHANCEDSTATUSCODES, and no parameter is used with that keyword.

The text part of all 2xx, 4xx and 5xx SMTP responses, other than the initial greeting and any response to HELO or EHLO, is prefaced with a status code as defined in RFC 1893. That status code is always followed by one or more spaces. The extension defines no additional SMTP verbs. The next section specifies how support for the extension affects the behaviour of a server and a client.

The server announces the feature once, in the greeting exchange. After that, most replies carry an extra code before their text.

§4The Status Code Syntax

Servers supporting the extension preface the text part of almost all response lines with a status code. As in RFC 1893, the syntax is given by this ABNF:

status-code ::= class "." subject "." detail
class       ::= "2" / "4" / "5"
subject     ::= 1*3digit
detail      ::= 1*3digit

These codes must appear in all 2xx, 4xx and 5xx response lines other than the initial greeting and any response to HELO or EHLO. 3xx responses are not included in this list.

All status codes returned by the server must agree with the primary response code: a 2xx response must incorporate a 2.X.X code, a 4xx response must incorporate a 4.X.X code, and a 5xx response must incorporate a 5.X.X code. When responses are continued across multiple lines, the same status code must appear at the beginning of the text in each line of the response. Servers supporting the extension must attach enhanced status codes to their responses regardless of whether or not EHLO is employed by the client.

The code has three parts separated by dots: the class of the reply, a subject and a detail. The class in the code must match the class of the reply it sits in, and a multi-line reply repeats the same code on every line.

THE THREE PARTS OF AN ENHANCED STATUS CODE
  • 2Class — The class of the reply: 2 for success, 4 for a temporary failure, 5 for a permanent failure.
  • 1*3digitSubject — A number that groups related conditions.
  • 1*3digitDetail — A number that names one specific condition.
THE SYNTAX OF A STATUS CODE, AS PRINTED IN RFC 2034
ABNF for the enhanced status code
status-code ::= class "." subject "." detail
class       ::= "2" / "4" / "5"
subject     ::= 1*3digit
detail      ::= 1*3digit

§5No Negotiation, on Purpose

This specification does not provide a means for clients to request that status codes be returned, or that they not be returned. A compliant server includes these codes in the responses it sends regardless of whether or not the client expects them.

This is somewhat different from most other SMTP extensions, where generally speaking a client must specifically make a request before the extended server behaves any differently than an unextended server. The omission of client negotiation is entirely intentional: given the generally poor state of SMTP server error code implementation, any step taken towards more comprehensible error codes is something that all clients, extended or not, should benefit from.

The RFC adds an important note: this approach should be seen as a very special case. It MUST NOT be taken as a license for future SMTP extensions to dramatically change the nature of SMTP client-server interaction without proper announcement from the server and a corresponding enabling command from the client.

Normally a client has to ask before a server changes its behaviour. Here it does not: the codes are always sent, because error replies are so often unclear that every client benefits from them. The RFC says this is a one-off exception, not a pattern to copy.

§6A Session With Enhanced Codes

The example shows a server that adds codes to its replies. After the greeting and the EHLO exchange, the server answers MAIL FROM with 250 2.1.0 and the first RCPT TO with 250 2.1.5. It rejects an unknown mailbox with 550 5.1.1 Mailbox "nosuchuser" does not exist, and refuses to forward with 551-5.7.1 Forwarding to remote hosts disabled, continued on the next line as 551 5.7.1 Select another host to act as your forwarder. The message is accepted with 250 2.6.0 Message accepted, and the session ends with 221 2.0.0 Goodbye.

The client that receives these responses might then send a non-delivery notification. For the mailbox that does not exist it records Action: failed, Status: 5.1.1 (Bad destination mailbox address) and a diagnostic code holding the server's reply. For the refused forwarding it records Status: 5.7.1 (Delivery not authorized, message refused). The reporting agent has omitted the enhanced status code information from the diagnostic-code fields it generated, to reduce clutter.

In the example, a server rejects a mailbox with the code 5.1.1 and refuses to forward with 5.7.1. The client copies those codes into the bounce message, so the sender learns the real reason.

THE EXAMPLE SESSION FROM RFC 2034, SECTION 6
SMTP clientSMTP server
  1. 220Greeting. It carries no status code.
  2. EHLO
  3. 250 ENHANCEDSTATUSCODESThe server announces the extension.
  4. RCPT TOA mailbox that does not exist.
  5. 550 5.1.1Mailbox does not exist.
  6. DATA
  7. 250 2.6.0Message accepted.

§7Security Considerations

Additional detail in server responses provides additional information about the server. It is conceivable that additional information of this sort may be of assistance in circumventing server security. The advantage of providing additional information must always be weighed against the security implications of doing so.

A more detailed reply also reveals more about the server. That extra detail might help someone trying to get around the server's protections, so the benefit has to be weighed against that risk.

§8References