<?xml version="1.0" encoding="US-ASCII"?>
<!-- This template is for creating an Internet Draft using xml2rfc,
     which is available here: http://xml.resource.org. -->
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!-- One method to get references from the online citation libraries.
     There has to be one entity for each item to be referenced. 
     An alternate method (rfc include) is described in the references. -->

<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC2629 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2629.xml">
<!ENTITY RFC5226 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5226.xml">
<!ENTITY RFC5248 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5248.xml">
<!ENTITY RFC5321 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5321.xml">
<!ENTITY RFC6376 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6376.xml">
<!ENTITY RFC6652 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6652.xml">
<!ENTITY RFC4408 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4408.xml">
<!ENTITY RFC3974 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3974.xml">
]>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<!-- used by XSLT processors -->
<!-- For a complete list and description of processing instructions (PIs), 
     please see http://xml.resource.org/authoring/README.html. -->
<!-- Below are generally applicable Processing Instructions (PIs) that most I-Ds might want to use.
     (Here they are set differently than their defaults in xml2rfc v1.32) -->
<?rfc strict="yes" ?>
<!-- give errors regarding ID-nits and DTD validation -->
<!-- control the table of contents (ToC) -->
<?rfc toc="yes"?>
<!-- generate a ToC -->
<?rfc tocdepth="4"?>
<!-- the number of levels of subsections in ToC. default: 3 -->
<!-- control references -->
<?rfc symrefs="yes"?>
<!-- use symbolic references tags, i.e, [RFC2119] instead of [1] -->
<?rfc sortrefs="yes" ?>
<!-- sort the reference entries alphabetically -->
<!-- control vertical white space 
     (using these PIs as follows is recommended by the RFC Editor) -->
<?rfc compact="yes" ?>
<!-- do not start each main section on a new page -->
<?rfc subcompact="no" ?>
<!-- keep one blank line between list items -->
<!-- end of list of popular I-D processing instructions -->
<rfc category="std" docName="draft-martin-smtp-ipv6-to-ipv4-fallback-00" ipr="trust200902" updates="5321">
  <!-- category values: std, bcp, info, exp, and historic
     ipr values: full3667, noModification3667, noDerivatives3667
     you can add the attributes updates="NNNN" and obsoletes="NNNN" 
     they will automatically be output with "(if approved)" -->

  <!-- ***** FRONT MATTER ***** -->

  <front>
    <!-- The abbreviated title is used in the page header - it is only necessary if the 
         full title is longer than 39 characters -->

    <title abbrev="SMTP IPv6 to IPv4 Fallback">SMTP IPv6 to IPv4 Fallback: An Applicability Statement</title>

    <!-- add 'role="editor"' below for the editors if appropriate -->

    <!-- Another author who claims to be an editor -->

    <author fullname="Franck Martin" initials="F.M." role="editor"
            surname="Martin">
      <organization>LinkedIn</organization>

      <address>
        <postal>
          <street></street>

          <!-- Reorder these if your country does things differently -->

          <city>Mountain View</city>

          <region>CA</region>

          <code></code>

          <country>US</country>
        </postal>

        <phone></phone>

        <email>fmartin@linkedin.com</email>

        <!-- uri and facsimile elements may also be added -->
      </address>
    </author>

    <author fullname="Alec Peterson" initials="A.P." role="editor"
            surname="Peterson">
      <organization>Message Systems</organization>

      <address>
        <postal>
          <street></street>

          <!-- Reorder these if your country does things differently -->

          <city>Columbia</city>

          <region>MD</region>

          <code></code>

          <country>US</country>
        </postal>

        <phone></phone>

        <email>alec@messagesystems.com</email>

        <!-- uri and facsimile elements may also be added -->
      </address>
    </author>


    <date month="November" year="2013" />

    <!-- If the month and year are both specified and are the current ones, xml2rfc will fill 
         in the current day for you. If only the current year is specified, xml2rfc will fill 
	 in the current day and month for you. If the year is not the current one, it is 
	 necessary to specify at least a month (xml2rfc assumes day="1" if not specified for the 
	 purpose of calculating the expiry date).  With drafts it is normally sufficient to 
	 specify just the year. -->

    <!-- Meta-data Declarations -->

    <area>apparea</area>

    <workgroup>Network Working Group</workgroup>

    <!-- WG name at the upperleft corner of the doc,
         IETF is fine for individual submissions.  
	 If this element is not present, the default is "Network Working Group",
         which is used by the RFC Editor as a nod to the history of the IETF. -->

    <keyword>SMTP</keyword>
    <keyword>IPv4</keyword>
    <keyword>IPv6</keyword>
    <keyword>MX</keyword>

    <!-- Keywords will be incorporated into HTML output
         files in a meta tag but they have no effect on text or nroff
         output. If you submit your draft to the RFC Editor, the
         keywords will be used for the search engine. -->

    <abstract>
      <t>This Applicability Statement describes how Mail Transfer Agents (MTAs) can be encouraged to fall back to IPv4 when a message is refused over IPv6.</t>
    </abstract>
  </front>

  <middle>
    <section title="Introduction">
      <t>The Simple Mail Transfer Protocol (SMTP) is defined in <xref target="RFC5321"></xref>. Section 5 of that document describes the process of host selection. SMTP clients in well known Mail Transfer Agent (MTA) software will retry a message using a different Mail Exchanger (MX) or network address if the message is temporarily rejected. This document describes under which circumstances well known and widely deployed open source MTAs (and others) can be made to retry over IPv4 when an initial connection to IPv6 results in a temporary rejection. Furthermore, the purpose of this document is to record that behaviour and encourage its further adoption while at the same time providing for the future a well defined mechanism via a service extension with cooperating SMTP clients. This behavior could be useful in, for instance, enforcing higher requirements for Simple Mail Transfer Protocol (SMTP) sessions over IPv6 than what exists on IPv4 without simply rejecting the message outright. </t>

    

      <section title="Moving from IP Reputation to Domain Based Reputation">
        <t>IPv6 brings more IP addresses, which means building an IP-based reputation system using IPv6 addresses could be difficult to achieve. Moving from an IP based reputation system to a domain based reputation system is expected to be easier. However, it requires that all SMTP servers participate. </t>

        <t>IPv4 address space is well known and many tools have been built to handle unwanted emails from certain IPv4 addresses. There is not yet such expertise on IPv6 nor tools. However, labels, like domain names are more stable, unlike the more dynamic nature of IP address allocation, and provide a relatively better chain to associate an email to its author, provided such labels can be authentified. Such labels allow better reporting of unwanted emails to the system administrators of mail servers in these domains.</t>

        <t>As IPv6 is still relatively nascent, there is a chance to mandate use of the Sender Policy Framework (SPF, <xref target="RFC4408"/>) or DomainKeys Identified Mail (DKIM, <xref target="RFC6376"/>) or similar domain-based authentication mechanisms for messages sent over IPv6 and, if these fail, to do retries over IPv4.</t>
      </section>

    </section>

      <section title="Requirements Language">
        <t>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 <xref
        target="RFC2119">RFC 2119</xref>.</t>
      </section>

    

    <section title="Indicating the sender-SMTP server to fall back to IPv4">
      <t>To move from IP based reputation to a domain based reputation system for email, a receiver-SMTP could, for example, require that messages pass <xref target="RFC6652">SPF</xref> or <xref target="RFC6376">DKIM</xref>. This section does not discuss the merit of such policy but proposes mechanisms for any policy to get the sender-SMTP to fall back to IPv4 from an IPv6 connection.</t>
      <section title="With the service extension IPV6-IPV4-FALLBACK ">
        <t>The receiver-SMTP MAY addvertise a service extension IPV6-IPV4-FALLBACK, which the sender-SMTP replies by IPV6-IPV4-FALLBACK if capable</t>
        <t>In this condition for each message not acceptable due to policy where a retry over IPv4 is requested, the sender-SMTP server MUST reply by the reply code 456, where the sender-SMTP requeues the message for immediate retry by selecting a receiver, according to Section 5 of <xref target="RFC5321"/>, that is at an IPv4 address..</t>
        <t>If there is no IPv4 address to be tried, the sender-SMTP SHOULD fail the message.</t>
        <t>If the receiver-SMTP implements <xref target="RFC5248">enhanced status codes</xref>, The SMTP enhanced status code SHOULD be 4.4.8.</t>
        <figure>
            <preamble>Example status message</preamble>
            <artwork><![CDATA[
            456 4.4.8 please retry immediately the message over IPv4 
            because it fails SPF and DKIM
            ]]></artwork>
        </figure>
        <t>The SMTP status code 456 is introduced in this document, and has a very specific meaning associated to the service extension. The SMTP enhanced status code is also introduced in this document, but like all enhanced status codes, they are usually not interpreted by the SMTP client, but for the bounce processor as to provide more meaningful reports to the mail administrator.</t>
      </section>
      <section title="Without service extension">
        <t>The receiver-SMTP server MUST have MX RR pointing to single stack hostnames and for same MX RR preference MUST have a MX RR pointing to an hostname with an A RR and a MX RR pointing to an hostname with an AAAA RR. No hostname pointed by a MX RR have a A RR and an AAAA RR.</t> 
        <figure>
            <preamble>For example:</preamble>
            <artwork><![CDATA[
      example.org.            IN MX   1  mx1-6.example.org.
                              IN MX   1  mx1.example.org
                              IN MX   10 mx10-6.example.org.
                              IN MX   10 mx10.example.org
      mx1-6.example.org.      IN AAAA 2001:db8:ffff::1
      mx1.example.org.        IN A    192.0.2.1
      mx10-6.example.org.     IN AAAA 2001:db8:ffff::2
      mx10.example.org        IN A    192.0.2.2      
            ]]></artwork>
          </figure>
        <t>When a receiver-SMTP makes a policy decision not to accept a message over IPv6, it rejects the message with a 451 code if done at connection time and 421 code if done later and terminates the connection so the sender-SMTP requeues the message for immediate retry by selecting a receiver, according to Section 5 of <xref target="RFC5321"/>, that is at an IPv4 address..</t>
        <t>If the receiver-SMTP implements <xref target="RFC5248">enhanced status codes</xref>, The SMTP enhanced status code SHOULD be 4.4.8.</t>
        <t>The rejection at connection time MAY be issued only when it has been demonstrated that a majority of messages would not pass the policy and that the sender-SMTP is not capable of the service extension IPV6-IPV4-FALLBACK.</t>
        <t>The rejection at connection time SHOULD be for a limited time to give a chance for later messages to be re-evaluted against the policy.</t>
        <t>456 is not used here, as it is a new SMTP status code introduced for clients that understand the service extension IPV6-IPV4-FALLBACK. It is not sure that sender-SMTP without this service extension would behave as expected with a new SMTP status code.</t>
        <t>Research presented in annexes has shown that common MTA exhibit this behavior.</t>
      </section>
    </section>

    <section anchor="Acknowledgements" title="Acknowledgements">
      <t>Thanks to Murray Kucheraway for guidance in getting this draft out.</t>

    </section>

    <!-- Possibly a 'Contributors' section ... -->

    <section anchor="IANA" title="IANA Considerations">
      <t>This section describes actions requested of IANA.</t>

      <section title="SMTP Enhanced Status Codes Registry update">
        <t>IANA is requested to add the following to the Simple Mail Transfer Protocol (SMTP) Enhanced Status Codes Registry:
        <list style="symbols">
          <t>Enumerated Status Codes</t>
          <t>Code: X.4.8</t>
          <t>Summary: retry on IPv4</t>
          <t>Associated basic status code: 421,451,456</t>
          <t>Description: the mail system will not accept this message over IPv6 because it lacks some requirments described in the full text of the rejection, however the sending mail system can retry immediately to submit the message over IPv4 only.</t>
        </list></t>
      </section>
      <section title="Simple Mail Transfer Protocol (SMTP) Service Extensions Registry update">
        <t>IANA is requested to add the following to the Simple Mail Transfer Protocol (SMTP) Service Extensions Registry:
        <list style="symbols">
          <t>Textual name: Capable to retry the message over IPv4 from IPv6 if requested</t>
          <t>EHLO Keyword: IPV6-IPV4-FALLBACK</t>
          <t>There is no parameters associated with the extension</t>
          <t>SMTP verb: IPV6-IPV4-FALLBACK</t>
          <t>Description: When the server indicates the service extension and the client indicates via the SMTP verb that it supports such extension, if the server rejects the message with the status code 456, the client will requeue the message to be delivered over IPv4.</t>
          <t>This extension does not increase the length of the MAIL and RCPT commands</t>
        </list></t>
      </section>
    </section>

    <section anchor="Security" title="Security Considerations">
      <t>SMTP clients might not not fall back to IPv4 when requested (by not implementing this proposal) and keep retrying on IPv6. MTA administrators ought to monitor for such servers, and could whitelist them to accept messages over IPv6 or take other action as appropriate.</t> 
      <t>Messages may start to queue on the sender-SMTP side and the mail administrator may not notice it or take appropriate action in time.</t>
      <t>If the policy is not explained clearly the mail administrator may not know what is required to pass the policy.</t>
      <t>If the policy is to cumbersome and is not based on widely adopted standards and recommendations, the mail administrator may decide not to jump through hoops to get the email delivered.</t>
      <t>The fall back mechanism without service extension may create unecessary burden for the sender as well as the receiver.</t>
    </section>
  </middle>

  <!--  *****BACK MATTER ***** -->

  <back>
    <!-- References split into informative and normative -->

    <!-- There are 2 ways to insert reference entries from the citation libraries:
     1. define an ENTITY at the top, and use "ampersand character"RFC2629; here (as shown)
     2. simply use a PI "less than character"?rfc include="reference.RFC.2119.xml"?> here
        (for I-Ds: include="reference.I-D.narten-iana-considerations-rfc2434bis.xml")

     Both are cited textually in the same manner: by using xref elements.
     If you use the PI option, xml2rfc will, by default, try to find included files in the same
     directory as the including file. You can also define the XML_LIBRARY environment variable
     with a value containing a set of directories to search.  These can be either in the local
     filing system or remote ones accessed by http (http://domain/dir/... ).-->

    <references title="Normative References">
      <!--?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml"?-->
      &RFC2119;

      &RFC5248;

      &RFC5321;

      &RFC6376;

      &RFC6652;

      &RFC4408;

    </references>

    <references title="Informative References">
      <!-- Here we use entities that we defined at the beginning. -->

      &RFC3974;

      &RFC5226;

    </references>
    <section anchor="app-additional" title="Examples and research">
      <section title="SMTP fall back from IPv6 to IPv4 without service extension">
         <figure>
            <preamble>The sender-SMTP server opens a connection to the receiver-SMTP example.org over IPv6, the message is refused because no domain authentication can be performed therefore the sender-SMTP retries immediately using IPv4. "S" indicates text sent by a server, and "C" indicates text sent by a client.  Line terminations are omitted in this illustration.</preamble>
            <artwork><![CDATA[
      S: 220 ipv6.example.com Simple Mail Transfer Service Ready
      C: EHLO example.org
      S: 250-ipv6.example.com greets example.org over IPv6
      S: 250-8BITMIME
      S: 250-SIZE
      S: 250-DSN
      S: 250 HELP
      C: MAIL FROM:<Smith@example.org>
      S: 250 OK
      C: RCPT TO:<Jones@example.com>
      S: 250 OK
      C: DATA
      S: 354 Start mail input; end with <CRLF>.<CRLF>
      C: [message body]
      C: .
      S: 421 4.4.8 message with no SPF or DKIM and over IPv6
      S: <disconnect>

      S: 220 ipv4.example.com Simple Mail Transfer Service Ready
      C: EHLO example.org
      S: 250-ipv4.example.com greets example.org over IPv4
      S: 250-8BITMIME
      S: 250-SIZE
      S: 250-DSN
      S: 250 HELP
      C: MAIL FROM:<Smith@bar.com>
      S: 250 OK
      C: RCPT TO:<Jones@example.com>
      S: 250 OK
      C: DATA
      S: 354 Start mail input; end with <CRLF>.<CRLF>
      C: [message body]
      C: .
      S: 250 OK
      C: QUIT
      S: 221 foo.com Service closing transmission channel

            ]]></artwork>
          </figure>
      </section>
      <section title="SMTP fall back from IPv6 to IPv4 with service extension">
         <figure>
            <preamble>The sender-SMTP server opens a connection to example.com over IPv6, the message is refused because no domain authentication can be performed therefore the sender-SMTP retries immediately using IPv4. "S" indicates text sent by a server, and "C" indicates text sent by a client.  Line terminations are omitted in this illustration.</preamble>
            <artwork><![CDATA[
      S: 220 ipv6.example.com Simple Mail Transfer Service Ready
      C: EHLO example.org
      S: 250-ipv6.example.com greets example.org over IPv6
      S: 250-8BITMIME
      S: 250-SIZE
      S: 250-DSN
      S: 250-IPV6-IPV4-FALLBACK 
      S: 250 HELP
      C: IPV6-IPV4-FALLBACK 
      S: 250 OK
      C: MAIL FROM:<Smith@bar.com>
      S: 250 OK
      C: RCPT TO:<Jones@example.com>
      S: 250 OK
      C: DATA
      S: 354 Start mail input; end with <CRLF>.<CRLF>
      C: [message body]
      C: .
      S: 456 4.4.8 message with no SPF or DKIM and over IPv6
      C: QUIT
      S: 221 foo.com Service closing transmission channel 

      Message is then retried immediately over IPv4
            ]]></artwork>
          </figure>
      </section>
      <section title="Common Open Source MTA Design">
        <t> This secton discusses current implementations in common open source MTAs. </t>

        <t>SMTP clients only interpret SMTP status codes, but the use of SMTP enhanced status codes can be used to better monitor and act on the reason of the temporary failure.</t>

        <t>For instance, at the end of DATA, if the message was sent over IPv6, the SMTP server can evalute whether the message passes SPF or DKIM and reject the message using 421 if neither pass.  If one passes, then an authenticated domain name is available and domain reputation rules can be applied. The IPv6 address of the SMTP client can be noted, and futher connections over IPv6 can be temporarily failed using the 451 status code for some period of time period so as to minimize resources to evaluate each message after the end of DATA.  On the other hand, if a message coming from an IPv6 address does not pass SPF or DKIM, it is unlikely that this state would quickly change for the next message coming from the same network address.</t>

        <t>For proprietary mail systems or large mailbox providers, they all do a form of domain authentication, either SPF or DKIM, so the above may not apply to them. Not all are yet enabled to send email over IPv6.</t>

        <t>Some observations:
        <list style="symbols">
          <t>When presented with a permanent failure code (5yz) during connection establishment, MTA clients will declare the message non deliverable and will not retry it on a different MX. Some clients do retry however.</t>
          <t>When an SMTP server rejects during the connection phase using the code 451 and disconnects, the SMTP client will typically retry the message immediately on a different MX.</t>
          <t>When an SMTP server rejects after the DATA phase using a 421 SMTP reply code followed by a disconnect, the SMTP client will retry the message immediately on a different MX.</t>
        </list></t>

        <t>MX RR configuration and the proper rejection need both to be properly defined.</t>

        <section title="MX RR configuration">
          <t>When a message is temporarily refused, using a 400-series SMTP error code, the strategy for the SMTP client is sometimes to retry immediately to a different MTA, as defined by the target selection process defined in <xref target="RFC5321"/>. </t>

          <t>When the new MX refers to a dual-stacked machine (see <xref target="RFC3974"/>), some MTA software will not pick up all of the A or AAAA RRs (Resource Records), but will instead select only the RRs matching the address family preferred by the local TCP/IP implementation.  Thus, MX RRs MUST NOT refer to dual-stacked machines.</t>

          <figure>
            <preamble>For instance, the following configuration is desired:</preamble>
            <artwork><![CDATA[
      example.org.            IN MX   10  mx1.example.org.
                              IN MX   10 mx1-6.example.org.
      mx1.example.org.        IN A    192.0.2.1
      mx1-6.example.org.      IN AAAA 2001:db8:ffff::1
          ]]></artwork>
          </figure>
          <t>In this configuration, the SMTP client see two MXes at the same preference, and will automatically pick one and try the other one if the message is properly temp-failed. Therefore, in the above example, if the first connection was over IPv6 and the message temporarly refused and the session disconnected, the next connection will be over IPv4. </t>
        </section>

        <section title="Rejecting Messages for Immediate Retry on IPv4">
        
        <figure>
          <preamble>Here is an example of an initial message sent over IPv6. The SMTP client then retries immediately on the next MX record, here an IPv4 address. "S" indicates text sent by a server, and "C" indicates text sent by a client.  Line terminations are omitted in this illustration. </preamble>  

          <artwork><![CDATA[
      C: <connection establishment>
      S: 220 example.net Simple Mail Transfer Service Ready
      C: EHLO example.com
      S: 250-example.net greets example.com over IPv6
      S: 250-8BITMIME
      S: 250-SIZE
      S: 250-DSN
      S: 250 HELP
      C: MAIL FROM:<Smith@example.com>
      S: 250 OK
      C: RCPT TO:<Jones@example.net>
      S: 250 OK
      C: DATA
      S: 354 Start mail input; end with <CRLF>.<CRLF>
      C: <message content>
      C: .
      S: 421 4.4.8 SPF and/or DKIM required on IPv6; try elsewhere
      C: QUIT
      S: 221 foo.com Service closing transmission channel
          ]]></artwork>
        </figure>
        <figure>
          <preamble>Where the client is known to not use DKIM and/or SPF, the server may terminate the connection immediately: </preamble>
          <artwork><![CDATA[
      C: <connection establishment>
      S: 451 4.4.8 Come back on IPv4 as I told you before
          ]]></artwork>
        </figure>
        </section>

        
      </section>
    </section>
  </back>
</rfc>
