<?xml version="1.0"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">

<?rfc compact='yes'?>
<?rfc toc='yes'?>


<!-- RFC references as names, not numbers -->
<?rfc symrefs="yes" ?>

<rfc ipr="full3978" docName="draft-hurtta-eai-encapsulation-01"
     category="exp">

   <front>
     <title abbrev="EAI Encapsulation">
Encapsulation mechanism for Internationalized Email     
     </title>      
     <author initials="K.E.H." surname="Hurtta" fullname="Kari Hurtta">
     <organization/>

     <address>
       <postal>
          <street>Kala-Matti 4 B 24</street>
          <city>02230 Espoo</city>
          <country>FI</country>
       </postal>

       <email>hurtta-ietf@elmme-mailer.org
       </email>
       <uri>http://iki.fi/keh/</uri>
     </address>

     </author>

     <date month="March" year="2007" />
     <workgroup>Email Address Internationalization (EAI)</workgroup>

     <abstract>
     <t>The Email Address Internationalization (EAI) is implemented 
        by allowing UTF-8 characters in SMTP envelope and mail 
        headers.  To deliver email which uses UTF-8 in email headers
        through EAI non-compliant environment converting (i.e downgrading)
        or encapsulation mechanism is required. Some UTF-8
        email may sign email headers or email header fields.
	This  document describes 
        mechanism for encapsulation when converting can not be used
        because of signed email headers. Encapsulation may also be
        used to forward EAI email through EAI non-compliant environment
        that way that original EAI email can be recovered. 
     </t>
     </abstract>

   </front>

   <middle>

       <section title="Introduction">
      
       <t>
       Internationalized email includes UTF-8 characters 
       <xref target="RFC3629" /> in email headers.
       When internationalized email is delivered to EAI non-compliant 
       environment it's email header fields are converted (i.e. downgraded) 
       to ASCII compatible form.  When email comes back EAI 
       compliant environment it is upgraded to internationalized form
       by decoding ASCII compatible encodings.
       </t>

       <t>
       When internationalized email is downgraded to ASCII 
       compatible form and then upgraded to internationalized form,
       the result is not necessary original mail. For example 
       some header fields may have originally used ASCII
       compatible form, but upgrading converts them to UTF-8 form.
       </t>
       
       <t>
       Sometimes, however, it be required that original
       internationalized email header part can be recovered. This
       document describes mechanism for 
       encapsulation which allows recovering the original 
       internationalized email.
       </t>

       <t>        
       If mail headers or some mail header fields and message parts 
       are cryptographically signed, this can require that 
       the original mail is recovered before signature of mail
       is checked. 
       </t>

       <t>This document provides an encapsulation method which
          has the following properties:
          <list style="symbols">
          <t>The encapsulation does not produce nesting encodings. </t>          
          <t>Content of an encapsulated mail is accessible to
              EAI non-compliant user agents. </t>
          <t>The encapsulation does not hide original MIME parts
             although original MIME structure may be obscured.</t>
          <t>The encapsulation provides way to recover a
             original internationalized email. </t>
          </list>
          Media types "multipart/utf8-encapsulated" and "text/utf8-header"
          are introduced.
       </t>

       <t>This document provides markup which indicates
          when downgrading to EAI non-compliant  environment
	  should be done with this encapsulation.
	  That is done by adding "Downgrade-Method: encapsulate"
          header field.
       </t>

       <t>If internationalized email is encapsulated, 
          "Downgrade-Method: encapsulated" header field
          is used.
       </t>

       <t>Only minimal amount of header fields are generated
          or left to header part of encapsulated message. 
	  This is used to hide signatures, which are placed 
	  to header fields, during encapsulation.
	  For example Domain Keys Identified Mail 
	  <xref target="DKIM-Charter"/> uses this kind of signatures.
          Original header fields are stored in "text/utf8-header" 
	  MIME part.
       </t>          

       <t>The "multipart/signed" media type <xref target="RFC1847" />
          signs header fields from MIME header. After encapsulation
          signature fails, because MIME header is changed.
          That signature is hidden by replacing "multipart/signed"
          in the "Content-Type" header field with "multipart/mixed" value. 
          Original "Content-Type"
          header field is stored in "text/utf8-header" MIME part.
       </t>

       <t>
         This encapsulation copies all header fields of internationalized email
         to "text/utf8-header" MIME part. Saved header fields
         from "text/utf8-header" MIME part and "Received" header fields
         from encapsulation email are used when upgrading. 
	 Because this may cause duplication
         of "Received" header fields, original "Received" header fields 
	 are renamed to 
         "I18N-Received" during encapsulation.
       </t>

       </section>

       <section title="Terminology">

       <t>Terminology for this document is defined in
          <xref target="ietf-eai-framework"/> and
	  <xref target="RFC2045"/>.
       </t>

       </section>


       

       <section title="Addition to internationalized email header">


       <t>
       New header fields are introduced.
       </t>

       <section title='"Downgrade-Method" header field'>


       <t>
       The "Downgrade-Method" header field is added to Internet Message Format
       <xref target="RFC2822"/> as specified  below:
       <vspace blankLines="1" />

       fields           /=  downgrade-method                            <vspace  blankLines="1" />

       downgrade-method  =  "Downgrade-Method:" downgrade-code CRLF     <vspace  blankLines="1" />

       downgrade-code     = "encapsulate" / "encapsulated"               <vspace  blankLines="1" />

       ; term <![CDATA[<fields>]]> is defined in <xref target="RFC2822"/>
       <vspace blankLines="1" />

       Value "encapsulate"  tells that downgrading is requested to be done 
       with the encapsulation defined in this document and value
       "encapsulated" indicates that downgrading is done with
       encapsulation defined in this document.
       </t>

       </section>

       <section  title='"I18N-Received" header field'>

       <t>
       The "I18N-Received" header field is added to Internet Message Format
       <xref target="RFC2822"/> as specified  below:
       <vspace blankLines="1" />

       received         /= "I18N-Received:" name-val-list ";" date-time CRLF <vspace  blankLines="1" />

       ; terms <![CDATA[<received>, <name-val-list> and <date-time>]]>  <vspace />
       ; are defined in <xref target="RFC2822"/>    
       <vspace blankLines="1" />
       
       Original "Received" header fields are renamed as  "I18N-Received" during 
       encapsulation. "Received" header fields are saved with original name to 
       "text/utf8-header" MIME part.
       </t>

       </section>     

       <section  title="Registration of Downgrade-Method header field">

       <t>
    This section provides the header field registration application (as per
   <xref target="RFC3864"/>).
       </t>

<t>       
   Header field name:  Downgrade-Method              <vspace blankLines="1" />

   Applicable protocol: mail                         <vspace blankLines="1" />

   Status: experimental                              <vspace blankLines="1" />

   Author/Change controller:                         <vspace blankLines="1" />
<list><t>
Kari Hurtta                                           <vspace />
hurtta-ietf@elmme-mailer.org                          <vspace />
</t></list>                                           <vspace blankLines="1" />


   Specification document(s): RFC &rfc.number;        <vspace blankLines="1" />

   Related information:                              <vspace blankLines="1" />
<list><t>
Downgrade-Method is used for signaling encapsulation with 
multipart/utf8-encapsulated media type.
</t></list>
</t>

       </section>

       <section  title="Registration of I18N-Received header field">

       <t>
    This section provides the header field registration application (as per
   <xref target="RFC3864"/>).
       </t>

<t>       
   Header field name:  I18N-Received                 <vspace blankLines="1" />

   Applicable protocol: mail                         <vspace blankLines="1" />

   Status: experimental                              <vspace blankLines="1" />

   Author/Change controller:                         <vspace blankLines="1" />
<list><t>
Kari Hurtta                                           <vspace />
hurtta-ietf@elmme-mailer.org                          <vspace />
</t></list>                                           <vspace blankLines="1" />


   Specification document(s): RFC &rfc.number;        <vspace blankLines="1" />

   Related information:                              <vspace blankLines="1" />
<list><t>
I18N-Received is used together with multipart/utf8-encapsulated
media type.
</t></list>
</t>

       </section>

      </section>



       <section title="Encapsulation format">

       <t>
       A "multipart/utf8-encapsulated" media type splits 
       internationalized email message <xref target="ietf-eai-utf8headers" />
       or MIME body part to two parts:
       <list  style="symbols">
             
       <t>The header part of internationalized email message
          or header part of MIME body part is put to first 
          body part of the "multipart/utf8-encapsulated" media 
          type. Media type of the first body part is "text/utf8-header".
       </t>

       <t>The body part of internationalized email message
          or header part of MIME body part is put to second body part
          of of the "multipart/utf8-encapsulated" media 
          type. Media type of the second body part is same than 
          the media type of original internationalized email message or 
	  the original MIME body part. However, if media type of
          original internationalized email message or 
	  original MIME body part was "multipart/signed" ,
	  media type of a second body part is "multipart/mixed".
	  In some cases media type is "application/octet-stream".
        </t>

       </list>
       </t>

        <t>
       <list style="hanging">
       <t hangText="NOTE:"> This encapsulation assumes that the "preamble" and 
          "epilogue" areas of multipart media types include
          only ASCII. If these areas include UTF-8 text, that
          text is lost if encapsulating "multipart/utf8-encapsulated"
          is converted to ASCII compatible format (i.e. 
          during 8BITMIME downgrading <xref target="RFC1652"/>.) 
        </t>
	<t><vspace blankLines="1" /></t>
	<t>
          This lost UTF-8 text on "preamble" and "epilogue" areas 
          of multipart media types can be solved by adding third
          and fourth body part to the "multipart/utf8-encapsulated" 
	  media type.  However author believes that this unnecessarily
          complicates encapsulation format and algorithm. The author
          assumes that messages which use signing do not put  
          UTF-8 text to "preamble" and "epilogue" areas 
          of multipart media types. If message is not signed, lost
          "preamble" and "epilogue" areas do not cause harm. 
	</t>
      </list>
      </t>

       <section title='"multipart/utf8-encapsulated" media type'>

       <t> The "multipart/utf8-encapsulated" can be used on three
           different roles. The "type" parameter is defined for
           "multipart/utf8-encapsulated" media type. Value
           of "type" parameter is defined as following: 
           <vspace blankLines="1" />

     type-value = "encapsulated" / "message" / "part"  <vspace blankLines="1" />
       
       <list style="symbols">
       <t>Value "encapsulated" is used, when "multipart/utf8-encapsulated" media 
          type is used as downgrading format of internationalized email. 
          Value of "type" is set to
          "encapsulated" when internationalized email is downgraded because of
          "downgrade=encapsulate" value on "Header-Type" header field.
       </t>
       <t>Value  "message" is used, when "multipart/utf8-encapsulated" media 
          type is used same purpose, to indicate which media type 
          "message/rfc822" is used for the non-EAI content.  Value of "type" 
	  is set to
          "message"  when internationalized email is attached to or included
           in the message. Roughly "multipart/utf8-encapsulated; type=message" 
	   is
           equivalent of "message/rfc822" except that format of attachment is 
          different.
       </t>
       <t>Value "part" is used, "multipart/utf8-encapsulated" media 
          type is used as downgrading format of MIME body part. 
           Value of "type" is set to "part" MIME structure of
           internationalized email or MIME body part is recursively 
           downgraded, and MIME body part with UTF-8 header is found.
       </t>
       </list>
       </t>


       </section>

       <section title="Registration of media type multipart/utf8-encapsulated">

       <t>
       This section provides the media type registration application (as per
   <xref target="RFC4288"/>).
       </t>

       <t>
   Type name: multipart                               <vspace blankLines="1" />

   Subtype name: utf8-encapsulated                     <vspace blankLines="1" />

   Required parameters:                               <vspace blankLines="1" />
<list><t>
    The "boundary" parameter is requires as per RFC 2046. <vspace blankLines="1" />

    The "type" parameter is required as per RFC &rfc.number;. <vspace blankLines="1" />
</t>
</list>

   Optional parameters:                               <vspace blankLines="1" />

   Encoding considerations:  8bit or binary           <vspace blankLines="1" />

   Security considerations:                           <vspace blankLines="1" />
<list>
<t>
This media type provides a method to encapsulate mail data. Specially this
media type provides a method to smuggle mail header fields so that mail scanners
do not see them. This may cause new security threats.
                                                     <vspace blankLines="1" />
</t>                                                 
<t>
This encapsulation does not hide original MIME parts. However, original MIME 
structure may be obscured. This may provide a method to smuggle MIME parts
so that mail scanners do not see them. This may cause new security threats.
                                                      <vspace blankLines="1" />
</t>                                                 
<t>
This encapsulation preserves only "Received" header fields from encapsulating 
message. This may hide information when encapsulated message is upgraded
to internationalized email format.
</t>
</list>                                               <vspace blankLines="1" />

   Interoperability considerations:                   <vspace blankLines="1" />
<list>
<t>
This media type  provides a method to encapsulate internationalized email.
Recipient of encapsulated email must decode encapsulation, before the email
is fully accessible. However original  MIME parts are not hidden from
mail agents which do not know encapsulation used by this media type.
</t>
</list>                                               <vspace blankLines="1" />

   Published specification:       RFC &rfc.number;    <vspace blankLines="1" />

   Applications that use this media type:             <vspace blankLines="1" />
<list>
<t>
Internationalized mail user agents (MUAs), mail transport agents (MTAs) and
IMAP servers.
</t>
</list>                                               <vspace blankLines="1" />

   Additional information:                            <vspace blankLines="1" />

<list><t>
     Magic number(s):                                 <vspace />
     File extension(s):                               <vspace />
     Macintosh file type code(s):                     <vspace />
</t></list>                                           <vspace blankLines="1" />


   <![CDATA[Person & email address]]> to contact for further information:  <vspace blankLines="1" />
<list><t>
Kari Hurtta                                           <vspace />
hurtta-ietf@elmme-mailer.org                          <vspace />
</t></list>                                           <vspace blankLines="1" />

   Intended usage: common                             <vspace blankLines="1" />

   Restrictions on usage:                             <vspace blankLines="1" />

   Author: Kari Hurtta                                <vspace blankLines="1" />

   Change controller: Kari Hurtta                     <vspace blankLines="1" />


       </t>


       </section>

       <section title="Registration of media type text/utf8-header">

       <t>
       This section provides the media type registration application (as per
   <xref target="RFC4288"/>).
       </t>

<t>

   Type name: text                                    <vspace blankLines="1" />

   Subtype name: utf8-header                          <vspace blankLines="1" />

   Required parameters:                               <vspace blankLines="1" />
<list><t>
    The "charset" with value "UTF-8", if UTF-8 header
    in fact is encapsulated.
</t>
</list>                                               <vspace blankLines="1" />

   Optional parameters:                               <vspace blankLines="1" />
<list><t>
     charset
</t>
</list>                                               <vspace blankLines="1" />

   Encoding considerations:  7bit or 8bit             <vspace blankLines="1" />
<list><t>
    "8bit", if UTF-8 header in fact is encapsulated.
</t>
</list>                           <vspace blankLines="1" />

   Security considerations:                           <vspace blankLines="1" />
<list>
<t>
This media type provides a method to encapsulate mail data. Specially this
media type provides a method to smuggle mail header fields so that mail scanners
do not see them. This may cause new security threats.
                                                      <vspace blankLines="1" />
</t>                                              
</list>

   Interoperability considerations:                    <vspace blankLines="1" />
<list>
<t>
Mail agents which do not know this media type, treat this as text/plain
media type.
</t>
</list>                                                <vspace blankLines="1" />

   Published specification:        RFC &rfc.number;    <vspace blankLines="1" />


   Applications that use this media type:             <vspace blankLines="1" />
<list>
<t>
Internationalized mail user agents (MUAs), mail transport agents (MTAs) and
IMAP servers.
</t>
</list>                                               <vspace blankLines="1" />


   Additional information:                            <vspace blankLines="1" />

<list><t>
     On some cases ASCII header part is encapsulated instead
     of UTF-8 header part.
</t>
</list>                                              <vspace blankLines="1" />

<list><t>
     Magic number(s):                                 <vspace />
     File extension(s):                               <vspace />
     Macintosh file type code(s):                     <vspace />
</t></list>                                           <vspace blankLines="1" />

   <![CDATA[Person & email address]]> to contact for further information: <vspace blankLines="1" />
<list><t>
Kari Hurtta                                           <vspace />
hurtta-ietf@elmme-mailer.org                          <vspace />
</t></list>                                           <vspace blankLines="1" />


   Intended usage: common                             <vspace blankLines="1" />

   Restrictions on usage:                             <vspace blankLines="1" />

   Author: Kari Hurtta                                <vspace blankLines="1" />

   Change controller: Kari Hurtta                     <vspace blankLines="1" />


</t>



        </section>   

       </section>


    <section title="Encapsulation">

    <t>On encapsulation the internationalized email message 
       or MIME body part
       is split to two MIME body parts of "multipart/utf8-encapsulated" media 
       type.
    </t>

    <t>There is three cases of encapsulation:
       <list style="symbols">
       <t>When internationalized email message is downgraded. </t>
       <t>When internationalized email message is attached to or included
           to message. </t>
       <t>When MIME body part is encapsulated because there is 
          UTF-8 text on header. This is in the recursive part of algorithm. 
       </t>
       </list>
       On <xref target="generic-encap">"Generic Encapsulation"</xref>  
       are described common parts of these three
       encapsulations.
     </t>

    <section anchor="generic-encap" title="Generic encapsulation">

    <t>
    Both an email message and MIME body part follow same general syntax:
    <list style="symbols">
    <t>Both have a header part and a body part.</t>
    <t>Header part is followed by body part and these are separated by an 
       empty line.</t>
    </list>
    Term "entity" refers to both an email message and a MIME body part.
    </t>

    <t>
    <list style="hanging">
      <t hangText="NOTE:"> Subtypes of "message" (i.e. media type is message/*)
       other than "message/rfc822" and other composite types
       than "multipart" or "message" are treated specially.
       This is done so that this algorithm is stable and result
       does not change when new subtypes of "message" are registered
       or new composite top level types are standardised.
       Unknown top level types are treated same way because it is
       not possible to know if the top level type is composite.
       Also in these cases type is treated as "application/octet-stream"
       if body part of original entity includes non-ASCII characters.
       Type information is not lost, because the whole header
       part of original entity is stored to the body of first MIME body part
       of the encapsulating entity.
       Processing as "application/octet-stream" is done because the algorithm
       does not know how to encapsulate it as a composite type. If
       the body part of original entity includes only ASCII characters,
       there can not be UTF-8 headers (when it is treated as 
       composite type).
      </t>
      </list>
    </t>

    <t>
    <list style="hanging">
      <t hangText="NOTE:"> This algorithm looks complex. This complexity 
      is result of the requirement that so called "the nested encoding rule"
      is not violated. This requirement causes that composite media
      types must be processed recursively. 
                                               <vspace blankLines="1" />
      </t>
      <t> Special handling of unknown composite types,
      which includes non-ASCII characters, as "application/octet-stream"
      causes that "the nested encoding rule" is violated. In case
      of unknown types this is unavoidable, because it is not possible
      to parse internal structure of unknown types.
      </t>
    </list>
    </t>

    <t>
    Encapsulating entity is generated from original
    internationalized email message or MIME body part in the following way:
    <list style="symbols">
      <t>New header part for encapsulating entity is generated. 
         <list>
         <t>Media type for encapsulating entity is 
            "multipart/utf8-encapsulated". </t>
         </list>
      </t>
      <t>New body part for encapsulating entity is generated.
         This body part consists two MIME body parts.
         <list>
         <t>Media type for first MIME body part is "text/utf8-header". 
            <list>
            <t>Value of "charset" parameter is "UTF-8", if 
	       header part of original entity includes UTF-8 characters.
	    </t>
	    <t>NOTE: This seems strange, but in certain cases also
               ASCII-only header part is encapsulated. In that case
	       "charset" parameter is not required.
	    </t>
            </list>
         </t>
         <t>Body part of the first MIME body part is the 
	    header part of original entity
            (original internationalized email message or MIME body part).
         </t>
	 <t>It is strongly recommended that the body of the 
	    first MIME body part
	    is base64 encoded (and of course "content-transfer-encoding" 
	    header field is updated correspondingly).
	 </t>
	 <t>Generation of second MIME body part is described in the next
	    chapters.
         </t>
        </list>
      </t>
    </list>
    </t>

    <t>
    <list style="hanging">
      <t hangText="NOTE:">An Unix mailbox format changes "From" on
      beginning of line to ">From". Therefore it is useful that
      "text/utf8-header" is encoded with base64 even when it 
      includes only ASCII header fields.
                                             <vspace blankLines="1" />
      </t>
      <t>
      Actually it is more common to replace "From " with ">From ". This
      does not touch "From" header field (if there is no space between
      "From" and ":").
      </t>
    </list>
    </t>

    <t>The second MIME body part of encapsulating entity is 
       generated in following way: 
       <list style="numbers">
       <t>Original entity is checked for following cases:
          <list style="symbols">
          <t>Media type value (type/subtype) of the original entity 
             includes other than ASCII characters
	     <xref target="ASCII"/>.
	     This is an error condition.
	  </t>
          <t>Media type of the original entity is a subtype of "message" 
             (i.e. media type is message/*) 
	     and it is not "message/rfc822" and the
	     body part of original entity includes non-ASCII character.
          </t>
          <t>Top level type of the original entity is unknown, the
	     body part of the original entity includes non-ASCII 
	     characters and 
	     encoding of the original entity is identity 
	     (i.e. "content-transfer-encoding" is "8bit" or "binary") 
	  </t>
          <t>Top level type of the original entity is other composite type
             than "multipart" or "message" and the body part of 
	     original entity 
	     includes non-ASCII characters.
	  </t>
          <t>Media type of the original entity is a subtype of "multipart"
	     (i.e. media type is multipart/*) and  "boundary" parameter
	     is missing.  This is an error condition. 
          </t>
          </list>
          If found,
          <list style="symbols">
            <t>Media type for the second MIME body part is 
	    "application/octet-stream"
            </t>
	    <t>Body part of the second MIME body part is body part of 
	       the original entity.
	    </t>
            <t>"Content-transfer-encoding" value for second MIME body part
	       is copied from the original entity, if it includes only ASCII
	       characters. Otherwise it is set to "7bit", "8bit" or "binary"
               as appropriate. Non-ASCII value is an error condition.
            </t>
           </list>
       </t>
       <t>Otherwise if the media type of original entity is "multipart/signed",
          then
       <list style="symbols">
          <t>Media type for the second MIME body part is "multipart/mixed"
          <list>
	    <t>Generation of the "boundary" parameter is described on
               next chapters. </t>
          </list>
          </t>
	  <t>Body part of the second MIME body part is 
	     "Composite encapsulated body 
	     part". Generation if this is described in the next chapters.
	  </t>
	  <t>"Content-transfer-encoding" is set to "7bit", "8bit" or 
	     "binary" as appropriate. 
	     <list>
	     <t>If the "Content-transfer-encoding" value of original entity
	        is other than  "7bit", "8bit" or "binary", this is an error
		condition.
	     </t>
	     </list>
	  </t>
       </list>

       </t>
       <t>Otherwise original entity is checked for following cases:
           <list style="symbols">
             <t>Top level type of original entity is other type
                than "multipart" or "message".
	        <list>
                   <t>This includes all discrete media types.</t>
                   <t>This includes all unknown top level types.</t>
	        </list>
              </t>
	      <t>Media type of original entity is subtype of "message" 
                 (i.e. media type is message/*) and it is not "message/rfc822".
	      </t>
           </list>
           If found,
           <list style="symbols">
	      <t>Media type for second MIME body part is same than media type
                 of original entity.
              <list>
                 <t>Copying of media type parameters from original entity
                    to second MIME body part is described on next chapters. 
                 </t>                 
	      </list>
	      </t>
              <t>Body part of second MIME body part is body part of original 
                 entity.
	      </t>
              <t>"Content-transfer-encoding" value for second MIME body part
	         is copied from original entity, if it includes only ASCII
	         characters. Otherwise it is set to "7bit", "8bit" or "binary"
                 as appropriate. Non-ASCII value is error condition.
            </t>
	   </list>
       </t>
       <t>Otherwise if original entity is composite type 
          ("multipart" or "message/rfc822"),
       <list style="symbols">   
	    <t>Media type for second MIME body part is same than media type
               of original entity.
               <list>
                 <t>Copying of media type parameters from original entity
                    to second MIME body part is described on next chapters. 
                 </t>                 
	      </list>
            </t>
            <t>Generation of body part for second MIME body part is handled 
               specially when media type of original entity is composite.
	       <list>
	       <t>Body of original entity is scanned when entity is composite. 
               </t>
               <t>Generally that causes that processing is recursive. </t>
	       <t>Body part of second MIME body part is called with term "composite 
                  encapsulated body part", if media type of original entity is 
		  composite.
                  Generating of this body part is described on next chapter. </t>
	        </list>
            </t>
	    <t>"Content-transfer-encoding" it is set to "7bit", "8bit" or 
	        "binary" as appropriate. 
	      <list>
	     <t>If "Content-transfer-encoding" value of original entity
	        is other than  "7bit", "8bit" or "binary", this is error
		condition.
	     </t>
	     </list>
	  </t>
       </list>
       </t>
       </list>       
    </t>

    <t>Media type parameters from original entity to second MIME body part is
       copied on following way
    <list style="symbols">  
        <t>This copying is done when media type for second MIME body part 
           is same than media type of original entity.
	</t>
        <t>ASCII parameters are copied (however see special note about 
	   "boundary" on next chapters.)
        </t>
	<t>UTF-8 comments are removed.
	</t>
	<t>Parameters which have UTF-8 value are encoded according
	   of <xref target="RFC2231" /> when copied.
           <list>
	   <t>If required parameters of media type are known, and
	      parameter is not required for media type, it is 
	      not required that it is copied (and encoded according 
              of <xref target="RFC2231" />).
	    </t>
	   </list>
	</t>
	<t>If parameter name have UTF-8 characters, this is error condition and
	   parameter is not copied.
	</t>
	<t>If "boundary" parameter value of multipart media type have 
	   UTF-8 characters,
	   it is handled specially. This is described on next chapters.
	</t>	    	
    </list> 
    </t>

    <t>
    The "Composite encapsulated body part" is generated in following way:
      <list style="symbols">  
      <t>If "application/octet-stream" was assigned to media type for 
         second MIME body part, 
         body part of original entity is
         resulting "Composite encapsulated body part". 
         This case is mentioned on previous chapter.
      </t>
      <t>If media type of original entity is subtype of "message" 
         (i.e. media type is message/*) and it is not "message/rfc822",
         body part of original entity is
         resulting "Composite encapsulated body part". 
         This case is mentioned on previous chapter.
      </t>
      <t>If media type of original entity is "message/rfc822", 
         body part of original entity parsed (to header and body part)
         and is processed as described on  
         <xref target="recursive-encap">"Encapsulation of recursive part"</xref>.
         Result of processing is "Composite encapsulated body part". 
      </t>
      <t>If media type of original entity is subtype of "multipart"
         (i.e. media type is multipart/*), body part of original entity
         is processed as described on next chapter.
         Result of processing is "Composite encapsulated body part". 
      </t>
      <t>If top level type of original entity is other composite type
         than "multipart" or "message", it is treated as unknown type.
         This processing is described on previous chapter.
      </t>
      </list>
    </t>

    <t>For multipart types "Composite encapsulated body part" is
       generated as following:
    <list style="numbers">  
    <t>A "boundary" parameter value from original entity is remembered.
       <list style="symbols">
       <t>Handling of missing "boundary" parameter is described on previous 
          chapters.</t>
       </list>
    </t>
    <t>A "boundary" parameter value for second MIME body part is selected.
       <list style="symbols">
       <t>Selected "boundary" parameter value must include only 
          ASCII characters.
       </t>
       <t>In general this can be same than a "boundary" parameter value from 
          original entity.</t>
       <t>If a "boundary" parameter value from original entity includes 
          UTF-8 characters, new ASCII-only value must selected.</t>
       </list>
    </t>
    <t>The "preamble" area from body of original entity is copied
       to "Composite encapsulated body part".
       <list style="symbols">
          <t>
          If "preamble" area includes non-ASCII characters, this is 
	  an error condition.
	  </t>
       </list>
    </t>
    <t>Body parts of multipart (from body of original entity) are handled:
    <list>
      <t>A boundary delimiter line is copied
         to "Composite encapsulated body part", but that way that 
         a boundary of original entity is replaced with selected boundary
         of second MIME body part.
      </t>
      <t>A body part is parsed (to header and body part) and is processed as 
         described on  
         <xref target="recursive-encap">"Encapsulation of recursive part"</xref>.
         Result is copied to "Composite encapsulated body part". 

      </t>
    </list>
    </t>
    <t>A final boundary delimiter line is copied 
       (from body of original entity), to 
       "Composite encapsulated body part" 
       but that way that 
       boundary of original entity is replaced with selected boundary
       of second MIME body part.
       <list style="symbols">
       <t>A final final boundary delimiter line is not generated to
           "Composite encapsulated body part" if a final boundary delimiter 
	   line is missing on original entity.
	   This is an error condition. 
       </t>
       </list>
    </t>
    <t>The "epilogue" area from body of original entity is copied
       to "Composite encapsulated body part".
       <list style="symbols">
          <t>
          If "epilogue" area includes non-ASCII characters, this is error
          condition.
	  </t>
       </list>
    </t>
    </list>
    </t>

    <t>
    <list style="hanging">
      <t hangText="NOTE:">The CRLF preceding the boundary delimiter line
      is conceptually attached to the boundary (as per <xref target="RFC2046" />). 
      That CRLF is not part of body part of multipart. If
      encapsulation and decoding of encapsulation process this CRLF
      different way, this encapsulation do not preserve all CRLFes
      or add extra CRLFes.
      </t>
    </list>
    </t>

    <t>
    <list style="hanging">
       <t hangText="NOTE:">If original "Content-transfer-encoding"
       includes non-ASCII characters, this algorithm do not
       able to decode resulting encapsulation. Therefore it is 
       recommended that internationalized email message is bounced 
       or rejected on that error condition.
       </t>
    </list>
    </t>

       <section anchor="recursive-encap" 
                title="Encapsulation of recursive part">

       <t>An encapsulation of recursive part is done following way:
       <list style="numbers">
          <t>If header part of recursive part includes UTF-8 characters
	     or if media type of recursive part is "multipart/signed"
             then
            <list style="symbols">
            <t>Recursive part is considered to be "original entity"
	       and <xref target="generic-encap">"Generic encapsulation"</xref> 
               is applied.
	    </t>
	    <t>Value of parameter "type" is set to "part" 
	       for resulting "multipart/utf8-encapsulated" 
	       encapsulating entity.
	    </t>
	    <t>Resulting encapsulating entity result is result
               for "Encapsulation on recursive part".
	    </t>
	    </list>
	  </t>
          <t>Otherwise if media type of recursive part is discrete,
             result for "Encapsulation on recursive part"
	     is recursive part itself.
	  </t>
	  <t>Otherwise if media type of recursive part is "message/rfc822",
	     then
            <list style="symbols">
	    <t>Header part of result for 
               "Encapsulation on recursive part" result,
	       is header part of recursive part.
	    </t>
	    <t>Body part of recursive part is parsed 
               (to header and body part)
               and is processed as described on  
               <xref target="recursive-encap">"Encapsulation of recursive part"</xref>.
	       Body part of result for "Encapsulation on recursive part" 
	       is result of processing.
	    </t>	    
	    </list> 
	  </t>
	  <t> Otherwise if top level type is multipart 
	      (i.e. media type is multipart/*) and
	      "boundary" parameter exists,
	      handling of it is described on next chapter.
            <list style="symbols">
	    <t>Missing "boundary" parameter on multipart types 
	       is error condition.
	    </t>
	    </list>
	  </t>

	  <t>Otherwise if recursive part is ASCII only (body is ASCII,
             i.e.  "content-transfer-encoding" is "7bit")
             result for "Encapsulation on recursive part"
	     is recursive part itself.
          </t>
	  <t>Otherwise if encoding of recursive part is not identity 
	     (i.e. "content-transfer-encoding" is not "8bit" or "binary") 
	     result for "Encapsulation on recursive part"
	     is recursive part itself.
          </t>  
	  <t>Otherwise
            <list style="symbols">
            <t>Recursive part is considered to be "original entity"
	       and <xref target="generic-encap">"Generic encapsulation"</xref> 
               is applied.
	    </t>
	    <t>For resulting "multipart/utf8-encapsulated" encapsulating entity
	       parameter "type" is set "part" as value.
	    </t>
	    <t>Resulting encapsulating entity result is result
               for "Encapsulation on recursive part".
	    </t>
	    <t>NOTE: This seems strange, but unknown composite media types 
	       are always encapsulated, if there is possibility
	       that they include embedded UTF-8 headers.
	    </t>
	    </list>
	  </t>

       </list>
       </t>


       <t>If top level type is multipart,
          result for "Encapsulation on recursive part"
	  is generated following way:
	  <list style="numbers">
	    <t>Header part of result for 
               "Encapsulation on recursive part" result
	       is header part of recursive part.
	    </t>
            <t>A "boundary" parameter value from recursive part is 
	       remembered.
              <list style="symbols">
              <t>Handling of missing "boundary" parameter is described on 
	         previous chapters.</t>
              </list>
            </t>
	    <t>Body part for "Encapsulation on recursive part" result
	       is initiated.
	    </t>
	    <t>A "preamble" area from body of recursive part is copied
		   to body part for "Encapsulation on recursive part" result.
                <list style="symbols">
                  <t>
                  If a "preamble" area includes non-ASCII characters, 
		  this is an error condition.
		  </t>
                </list>
	    </t>
	    <t>Body parts of multipart (from body of recursive part) are handled:
	    <list>
	       <t>A boundary delimiter line is copied
	          to body part for "Encapsulation on recursive part" result.
	       </t>
	       <t>A body part is parsed (to header and body part) and is 
	          processed as described on  
		  <xref target="recursive-encap">"Encapsulation of recursive part"</xref>.
		  Result is copied to 
		  body part for "Encapsulation on recursive part" result.
	       </t>
            </list>
            </t>
            <t>A final boundary delimiter line is copied 
	       (from body of recursive part) to 
	       body part for "Encapsulation on recursive part" result.
               <list style="symbols">
	       <t>A final final boundary delimiter line is not generated to
                 body part for "Encapsulation on recursive part" result 
		 if final boundary delimiter 
	         line is missing on recursive part.
		 This is an error condition. 
	       </t>
	       </list>
	    </t>
	    <t>An "epilogue" area from body of recursive part is copied
		   to body part for "Encapsulation on recursive part" 
		   result.
                <list style="symbols">
                  <t>
                  If "epilogue" area includes non-ASCII characters, 
		  this is error condition.
		  </t>
                </list>
	    </t>
          </list>
       </t>
	 
       </section>


       <section title="Encapsulation example">

       <figure>
        <preamble>
	An encapsulation example
	</preamble>

<artwork>
    Original internationalized entity:

    ==========================================
    Some-Header: { UTF-8 content }
    Content-Type: Text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit

    { UTF-8 text }
    ==========================================

    Encapsulated entity:

    ==========================================
    Content-Type: multipart/utf8-encapsulated; 
      type={specified later}; boundary="12345"
    Content-Transfer-Encoding: 8bit


    --12345
    Content-Type: text/utf8-header; charset=UTF-8
    Content-Transfer-Encoding: 8bit

    Some-Header: { UTF-8 content }
    Content-Type: Text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit

    --12345
    Content-Type: Text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    { UTF-8 text }

    --12345--
    ==========================================
    
</artwork>
       <postamble>
         An empty line on end of "text/utf8-header" body is not
         copied from original encapsulated headers. 
         It is part of next boundary
         line of "multipart/utf8-encapsulated".
       </postamble>
       </figure>

        <t>
        <list style="hanging">
           <t hangText="NOTE:">On this example "text/utf8-header"
	   part is not base64 encoded for clarity. Base64 encoding
	   is recommended.
	   </t>
	</list>
	</t>
       </section>

       <section title="Multipart encapsulation example">

       <figure>
        <preamble>

        An multipart encapsulation example
        </preamble>

<artwork>
    Original internationalized entity:

    ==========================================
    Content-Type: Multipart/mixed; boundary=12345
    Content-Transfer-Encoding: 8bit


    --12345
    Some-Header: { UTF-8 content }
    Content-Type: Text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit

    { UTF-8 text }

    --12345
    ==========================================

    Encapsulated entity:

    ==========================================
    Content-Type: multipart/utf8-encapsulated; 
      type={specified later}; boundary="67890"
    Content-Transfer-Encoding: 8bit


    --67890
    Content-Type: text/utf8-header; charset=US-ASCII
    Content-Transfer-Encoding: 7bit

    Content-Type: Multipart/mixed; boundary=12345
    Content-Transfer-Encoding: 8bit

    --67890
    Content-Type: Multipart/mixed; boundary=12345
    Content-Transfer-Encoding: 8bit


    --12345
    Content-Type: multipart/utf8-encapsulated; 
      type=part; boundary="abcde"
    Content-Transfer-Encoding: 8bit


    --abcde
    Content-Type: text/utf8-header; charset=UTF-8
    Content-Transfer-Encoding: 8bit

    Some-Header: { UTF-8 content }
    Content-Type: Text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit

    --abcde
    Content-Type: Text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit

    { UTF-8 text }

    --abcde--

    --12345--

    --67890--
    ==========================================


</artwork>
      <postamble>
         "Generic encapsulation" causes that a top level header part
         is always encapsulated, even when it is US-ASCII only.
         In general it is assumed that on internationalized email
         there is always some header fields which require this
         encapsulation.
       </postamble>
       </figure>

       </section>

       <section title="Unknown top level type encapsulation example #1">

       <figure>
        <preamble>

	  An encapsulation example for unknown top level type 
	  with 7-bit body     
	</preamble>

<artwork>
    Original internationalized entity:

    ==========================================
    Some-Header: { UTF-8 content }
    Content-Type: X-message8/plain
    Content-Transfer-Encoding: 7bit

    { ASCII text }
    ==========================================


    Encapsulated entity:

    ==========================================
    Content-Type: multipart/utf8-encapsulated; 
      type={specified later}; boundary="12345"
    Content-Transfer-Encoding: 8bit


    --12345
    Content-Type: text/utf8-header; charset=UTF-8
    Content-Transfer-Encoding: 8bit

    Some-Header: { UTF-8 content }
    Content-Type: X-message8/plain
    Content-Transfer-Encoding: 7bit

    --12345
    Content-Type: X-message8/plain
    Content-Transfer-Encoding: 7bit

    { ASCII text }

    --12345--
    ==========================================
</artwork>
       </figure>

       </section>   


       <section title="Unknown top level type encapsulation example #2">

       <figure>
        <preamble>

	  An encapsulation example for unknown top level type 
	  with 8-bit body     
	</preamble>

<artwork>
    Original internationalized entity:

    ==========================================
    Some-Header: { UTF-8 content }
    Content-Type: X-message8/plain
    Content-Transfer-Encoding: 8bit

    { non-ASCII text }
    ==========================================

    ==========================================
    Content-Type: multipart/utf8-encapsulated; 
      type={specified later}; boundary="12345"
    Content-Transfer-Encoding: 8bit


    --12345
    Content-Type: text/utf8-header; charset=UTF-8
    Content-Transfer-Encoding: 8bit

    Some-Header: { UTF-8 content }
    Content-Type: X-message8/plain
    Content-Transfer-Encoding: 8bit

    --12345
    Content-Type: application/octet-stream
    Content-Transfer-Encoding: 8bit

    { non-ASCII text }

    --12345--
    ==========================================
</artwork>
       </figure>

       </section>   


    </section>

    <section title="Downgrading of internationalized email message">

    <t>
    When an internationalized email <xref target="ietf-eai-utf8headers" /> 
    leaves EAI compliant environment 
    downgrade is required. <xref target="ietf-eai-downgrade" /> describes 
    when downgrade occurs. 
    </t>

    <t>This document defines "Downgrade-Method" header field. 
       Downgrading method is selected following way:
       <list style="symbols">
         <t>If "Downgrade-Method" header field value is "encapsulate", 
            downgrading of header part (and body) of mail is done as 
            described on this section.
         </t>
         <t>Otherwise all message headers  (including header fields 
            from MIME body parts) may need to be parsed to
            discover that message is internationalized email and
            is downgrading candidate. 
            <list style="symbols">
	      <t>If a downgrading gateway is configured for tunneling 
                 operation for some recipients of mail, downgrading
                 of header part (and body) of mail for these recipients 
                 is done as described on this section. 
              </t>
              <t>If "Downgrade-Method" header field header field does not 
                 exists and a downgrading gateway is not configured for 
                 tunneling operation, downgrading of header part (and body) 
                 of mail is done according of <xref target="ietf-eai-downgrade" />.
	      </t>
              <t>If "Downgrade-Method" header field exists and it's
                 value is not "encapsulate", this specification is not
                 used for downgrading of header part (and body) of mail.
              </t>
            </list>
	 </t>
        </list>
    </t>
    
    <t>Downgrading of internationalized email is done following way:
     <list style="symbols">
     <t>Internationalized email is considered to be "original entity"
	and <xref target="generic-encap">"Generic encapsulation"</xref> 
        is applied.
     </t>
     <t>For resulting "multipart/utf8-encapsulated" encapsulating entity
	parameter "type" is set "encapsulated" as value.
     </t>
     <t>Resulting encapsulating entity is downgraded internationalized 
        email.
	<list>
        <t>Addition of email header fields to downgraded internationalized 
           email is described on next chapter.
	</t>
	</list>
     </t>

     </list>
    </t>

    <t>When mail is downgraded, some email header fields must be added.   
       <xref target="generic-encap">"Generic encapsulation"</xref> 
       do not produce these email header fields.
       <list style="symbols">
       <t>"Downgrade-Method" header field with value "Encapsulated" is added.
       </t>

       <t>"Received" header fields are copied from original
          international email added with new header field name.
	  "I18N-Received" header field name is used for copied
	  header fields. If "for" clause on "Received" header field
	  includes non-ASCII, it is removed when "Received" header field
	  is copied to "I18N-Received" header field.
          If some header field (excluding "for" clause) includes non-ASCII
	  characters, it is not copied.
       </t>
       <t>"Mime-Version" header field with value "1.0" is added.
       </t>
       <t>"Date" header field is copied from original
          international email, if it includes only ASCII
	  characters.  Otherwise it is generated.
       </t>
       <t> "From" header field is added. Several different values
           for "From" header field which can be used:
	   <list>
	   <t>If "From" header field from original
              internationalized email can be used, if it includes 
	      only ASCII characters.
	   </t>
	   <t>Algorithm from <xref target="ietf-eai-downgrade" />
	      can be used.
	   </t>
	   <t>Value for "From" header field can be taken from
	      downgraded envelope sender address.
	   </t>
	   <t>ASCII address which refers of a downgrading gateway, 
              can be used.
	   </t>
	   </list>
       </t>
       <t>"Subject" header field is copied from original
          internationalized  email, if it includes only ASCII
	  characters.  Otherwise several different values
           for "Subject" header field can be used:	  
          <list>
            <t>Algorithm from <xref target="ietf-eai-downgrade" />
	       or from <xref target="RFC2047" /> can be used.
	    </t>
	    <t>ASCII subject which refers to downgrading operation,
               can be used.
	    </t>
	  </list>
       </t>

       <t>If "From" and "Subject" are from original
          internationalized  email and "Message-ID" header field
	  on original internationalized  email includes only ASCII
	  characters,  "Message-ID" header field is copied
          (from original internationalized  email).
          Otherwise it is optionally generated.
       </t>

       <t>Optionally "To" header is added. Several different values
          for "To" header field which can be used:
       <list>
	   <t>"To" header field from original
              international email can be used, if it includes 
	      only ASCII characters.
	   </t>
	   <t>Algorithm from <xref target="ietf-eai-downgrade" />
	      can be used.
	   </t>
       </list>
       </t>

       <t>Optionally "Cc" header is added. Several different values
          for "Cc" header field which can be used:
       <list>
	   <t>"Cc" header field from original
              international email can be used, if it includes 
	      only ASCII characters.
	   </t>
	   <t>Algorithm from <xref target="ietf-eai-downgrade" />
	      can be used.
	   </t>
       </list>
       </t>


       <t>It is important that all ASCII header fields are NOT
          copied. Some header fields may be used for signatures.
	  If signature is checked from encapsulated form, it
	  fails. For example Domain Keys Identified Mail 
	  <xref target="DKIM-Charter"/> uses these kind 
	  signatures.
       </t>
       </list>
    </t>

    <t>
    <xref target="recursive-encap">"Encapsulation on recursive part"</xref>
    mentions several error conditions. Although it defines output on
    that case converting MTA is permitted to bounce (return NDN) or reject
    (on SMTP level) internationalized email message. Downgrading MUA
    can refuse downgrading internationalized email message and give
    error message to user or produce downgraded message and give 
    warning message to user. Silent operation is not recommended
    when error condition happens (on downgrading MUA).
    </t>

    <t>
    <list style="hanging">
      <t hangText="NOTE:">Only "Date" and "From" header fields 
        are required on email (as per <xref target="RFC2822" />)
                                                <vspace blankLines="1" />
      </t>
      <t>
      However "multipart/utf8-encapsulated" format is also usable
      for non-EAI compliant MUAs  assuming that they
      support MIME. Specially if an original internationalized email
      message was using UTF-8 characters only on main header part and not
      on header part of MIME body parts. Therefore it is useful if
      "From", "Subject", "To" and "Cc" header fields are derived from
      original internationalized email according  of 
      <xref target="ietf-eai-downgrade" />. This allows 
      reply -commands work on non-EAI compliant MUAs.
      </t>

    </list>
    </t>






      <section  anchor="encap-mail-mail"  
              title="Encapsulation example">

      <figure>
        <preamble>
	An encapsulation example 
	</preamble>

<artwork>
    Original internationalized email:

    ==========================================
    Received: from {idn-encoded-name} 
        by downgrade.example.org with ESMTP 
        id JGR17356; 
        Wed, 13 Sep 2006 22:27:25 +0300
    Downgrade-Method: encapsulate
    From: { UTF-8 address }
    To: someone@example.org
    Date: Wed, 13 Sep 2006 22:27:25 +0300
    Subject: { UTF-8 subject }
    X-Foobar: XvrT
    Mime-Version: 1.0
    Content-Type: Text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit

    { UTF-8 text }
    ==========================================

    Encapsulated internationalized email:

    ==========================================
    I18N-Received: from {idn-encoded-name} 
        by downgrade.example.org with ESMTP 
        id JGR17356; 
        Wed, 13 Sep 2006 22:27:25 +0300
    Downgrade-Method: Encapsulated
    From: { downgraded address }
    To: someone@example.org
    Date: Wed, 13 Sep 2006 22:27:25 +0300
    Subject: { RFC 2047 encoded subject }
    Mime-Version: 1.0
    Content-Type: multipart/utf8-encapsulated; 
      type=encapsulated; boundary="12345"
    Content-Transfer-Encoding: 8bit


    --12345
    Content-Type: text/utf8-header; charset=UTF-8
    Content-Transfer-Encoding: 8bit

    Received: from {idn-encoded-name} 
        by downgrade.example.org with ESMTP 
        id JGR17356; 
        Wed, 13 Sep 2006 22:27:25 +0300
    Downgrade-Method: encapsulate
    From: { UTF-8 address }
    To: someone@example.org
    Date: Wed, 13 Sep 2006 22:27:25 +0300
    Subject: { UTF-8 subject }
    X-Foobar: XvrT
    Mime-Version: 1.0
    Content-Type: Text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit

    --12345
    Content-Type: Text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit

    { UTF-8 text }

    --12345--
    ==========================================

</artwork>
      </figure>

        <t>
        <list style="hanging">
           <t hangText="NOTE:">On this example "text/utf8-header"
	   part is not base64 encoded for clarity. Base64 encoding
	   is recommended -- especially because it includes line
	   starting with "From".
	   </t>
	</list>
	</t>

      </section>

      <section title="Multipart/signed encapsulation example">

      <figure>
        <preamble>
	Multipart/signed <xref target="RFC1847" /> encapsulation example 
	</preamble>

<artwork>
    Original internationalized email:

    ==========================================
    Received: from {idn-encoded-name} 
        by downgrade.example.org with ESMTP 
        id JGR17356; 
        Wed, 13 Sep 2006 22:27:25 +0300
    Downgrade-Method: encapsulate
    From: { UTF-8 address }
    To: someone@example.org
    Date: Wed, 13 Sep 2006 22:27:25 +0300
    Subject: { UTF-8 subject }
    X-Foobar: XvrT
    Mime-Version: 1.0
    Content-Type: multipart/signed; 
            protocol="application/XYZ-signature";
            micalg="ABC"; boundary=12345
    Content-Transfer-Encoding: 8bit


    --12345
    Content-Description: { UTF-8 description }   
    Content-Type: Text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit

    { UTF-8 text }

    --12345
    Content-Type: application/XYZ-signature

    { signature data }

    --12345--
    ==========================================

    Encapsulated internationalized email:

    ==========================================
    I18N-Received: from {idn-encoded-name} 
        by downgrade.example.org with ESMTP 
        id JGR17356; 
        Wed, 13 Sep 2006 22:27:25 +0300
    Downgrade-Method: Encapsulated
    From: { downgraded address }
    To: someone@example.org
    Date: Wed, 13 Sep 2006 22:27:25 +0300
    Subject: { RFC 2047 encoded subject }
    Mime-Version: 1.0
    Content-Type: multipart/utf8-encapsulated; 
      type=encapsulated; boundary="45678"
    Content-Transfer-Encoding: 8bit


    --45678
    Content-Type: text/utf8-header; charset=UTF-8
    Content-Transfer-Encoding: 8bit

    Received: from {idn-encoded-name} 
        by downgrade.example.org with ESMTP 
        id JGR17356; 
        Wed, 13 Sep 2006 22:27:25 +0300
    Downgrade-Method: encapsulate
    From: { UTF-8 address }
    To: someone@example.org
    Date: Wed, 13 Sep 2006 22:27:25 +0300
    Subject: { UTF-8 subject }
    X-Foobar: XvrT
    Mime-Version: 1.0
    Content-Type: multipart/signed; 
            protocol="application/XYZ-signature";
            micalg="ABC"; boundary=12345
    Content-Transfer-Encoding: 8bit

    --45678
    Content-Type: multipart/mixed; 
            boundary=12345
    Content-Transfer-Encoding: 8bit


    --12345
    Content-Type: multipart/utf8-encapsulated; 
      type=part; boundary="abcde"
    Content-Transfer-Encoding: 8bit


    --abcde
    Content-Type: text/utf8-header; charset=UTF-8
    Content-Transfer-Encoding: 8bit

    Content-Description: { UTF-8 description }   
    Content-Type: Text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit

    --abcde
    Content-Type: Text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit

    { UTF-8 text }

    --abcde--

    --12345
    Content-Type: application/XYZ-signature

    { signature data }

    --12345--

    --45678--
    ==========================================

</artwork>
      <postamble>
      Media type "multipart/signed" is replaced
      with "multipart/mixed" on encapsulated message.
      This allows encapsulation of signed header
      on MIME body part.
      </postamble>
      </figure>

        <t>
        <list style="hanging">
           <t hangText="NOTE:">Again,  "text/utf8-header" should be
	   base64 encoded. It is not done for clarity.
	   </t>
	</list>
	</t>

        <t>
        <list style="hanging">
	<t hangText="NOTE:">Normally various multipart/signed protocols
	  defined that body of signed content must be quoted-printable
	  or base64 encoded if it includes 8-bit characters.  If it 
	  includes 8-bit characters, signature is broken, when email
	  is 8BITMIME downgraded <xref target="RFC1652"/>. Note that
	  generally  this encapsulation algorithm do not protect against 
	  breaking of signature on that case. On that example is may 
	  protect it, but that is side effect protection required for 
	  encapsulation of "Content-Description" header field.
	</t>
	</list>
	</t>

      </section>

    </section>

    <section title="Attaching internationalized email message">

    <t>
    "Message/rfc822" can be used to attach internationalized email 
    messages on EAI compliant environments if "message/rfc822"
    allows UTF-8 header fields. 
    "Multipart/utf8-encapsulated" with "type"
    parameter value "message" can be used to attach internationalized email 
    messages on EAI non-compliant environments.
    </t>
    
    <t>
    <list style="hanging">
      <t hangText="NOTE:">When inside of "message/rfc822" have 
      "Multipart/utf8-encapsulated" with "type" parameter value 
      "encapsulated", this also represents attached internationalized 
      email message.  However author believes that 
      "multipart/utf8-encapsulated" with "type" parameter value "message"
      provides useful shorthand. 
                                               <vspace blankLines="1" />
      </t>
      <t hangText="NOTE:">If internationalized email was stored
      inside of "message/rfc822" media type and "message/rfc822"
      is inside of mime structure which is encapsulated,
      <xref target="recursive-encap">"Encapsulation on recursive part"</xref>
      produces where inside of "message/rfc822" have 
      "Multipart/utf8-encapsulated" with "type" parameter 
      value "part".
      </t>
    </list>
    </t>

    <t>"Multipart/utf8-encapsulated" media type, which represents
       internationalized email message, is done following way:
       <list style="symbols">
       <t>Internationalized email is considered to be "original entity"
	  and <xref target="generic-encap">"Generic encapsulation"</xref> 
          is applied.
       </t>
       <t>Value of parameter "type" is set to  "message" 
          for resulting "multipart/utf8-encapsulated" encapsulating entity.
       </t>
       </list>
    </t>


        <section title="Attaching example">

        <figure>
          <preamble>
          On following example mail 
	  from <xref target="encap-mail-mail">earlier example</xref>
	  is attached to message, which is sent to outside of
	  EAI compliant environment.
	  </preamble>

<artwork>

    Encapsulating message:

    ==========================================
    From: someone@example.org
    To: A@CC.example.org
    Subject: { UTF-8 subject } (fwd)
    Mime-Version: 1.0
    Content-Type: multipart/mixed;
       boundary="12345"
    Content-Transfer-Encoding: 8bit


    --12345
    Content-Type: Text/plain

    See attached message.

    --12345
    Content-Type: multipart/utf8-encapsulated;
       type=message; boundary="67890"
    Content-Transfer-Encoding: 8bit


    --67890
    Content-Type: text/utf8-header; charset=UTF-8
    Content-Transfer-Encoding: 8bit

    Downgrade-Method: encapsulate
    From: { UTF-8 address }
    To: someone@example.org
    Date: Wed, 13 Sep 2006 22:27:25 +0300
    Subject: { UTF-8 subject }
    X-Foobar: XvrT
    Mime-Version: 1.0
    Content-Type: Text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit

    --67890
    Content-Type: Text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit

    { UTF-8 text }

    --67890--

    --12345--
    ==========================================

</artwork>
      </figure>

      <t>In this example it is assumed that MUA knows
         that A@CC.example.org do not handle UTF8SMTP 
	 messages and therefore encapsulates it.  Recipient 
         (A@CC.example.org) may need helper
	 application for media type  multipart/utf8-encapsulated
	 although message is mostly readable without helper.
      </t>
	</section>

    </section>   


    </section>


    <section title="Decoding encapsulation">

    <t>There is three cases of encapsulation:
    <list style="symbols">
    <t>When internationalized email message is tunneled through
       EAI non-compliant environment, media type of
       message is "multipart/utf8-encapsulated" with "type" parameter
       value "encapsulated". Original message is inside of
       that type. 
    </t>
    <t>When internationalized email message is included or attached
        message, media type "multipart/utf8-encapsulated" with "type" 
	parameter value "message" represents included or attached
	message.
    </t>
    <t>When MIME body part is encapsulated, media type 
       "multipart/utf8-encapsulated" with "type" parameter value 
       "part" encapsulates original MIME body part.       
    </t>
    </list>
    On <xref target="generic-decod">"Generic decoding"</xref> 
    is described common parts of decoding these three
    encapsulations.
    </t>


    <section anchor="generic-decod" title="Generic decoding">

    <t>On decoding an internationalized email message or a MIME body part
       from "multipart/utf8-encapsulated" are extracted. Both
       an email message and a MIME body part are refereed with term "entity".
    </t>

    <t>On error conditions encapsulating entity is not decoded.
       Instead original encapsulating entity is returned.
    </t>

    <t>Decoded internationalized entity is generated from encapsulating
       entity (multipart/utf8-encapsulated)  in following way:
    <list style="symbols">
       <t>If media type of an encapsulating entity is not
          "multipart/utf8-encapsulated", this is an error condition.
       </t>
       <t>If number of MIME body parts on encapsulating entity
          is not two (2), this is an error condition.
       </t>
       <t>If media type of first MIME body part is not "text/utf8-header",
          this is an error condition.
       </t>
       <t>If value of "charset" parameter of first MIME body part is not
          "UTF-8" or "US-ASCII", this is an error condition. Missing
	  "charset" parameter is treated as equivalent of "US-ASCII"
	  as per <xref target="RFC2046" />.
       </t>
       <t>Body of first MIME body part forms header part of decoded
          entity. Encoding (as given on "content-transfer-encoding"
	  header field) is decoded. 
       </t>
       <t>Body of second MIME body parts forms body part of decoded
          entity. Generating of body part of decoded
          entity is described on next chapter.</t>
    </list>
    </t>

    <t>Body of decoded entity is generated on following way:
    <list style="symbols">
      <t>If both media type of second MIME body part is discrete 
         and
         media type for decoded entity (from body of first MIME body part)
         is discrete, then
      <list>
         <t>If encoding for decoded entity (from body of first 
	    MIME body part) is identity (i.e. "content-transfer-encoding"
	    is "7bit", "8bit" or "binary")
	    <list>
	      <t>Body of second MIME body parts forms body part of decoded
                 entity.
	      </t>
	      <t>Encoding (as given on "content-transfer-encoding"
	         header field on second MIME body part) is decoded. 
	      </t>
            </list>
	 </t>
	 <t>If encoding for decoded entity (from body of first 
	    MIME body part) is same than encoding of second MIME body part,
	    <list>
	      <t>Body of second MIME body parts forms body part of decoded
                 entity.
	      </t>
	      <t>Encoding is not decoded. </t>
	    </list>	 
	  </t>
	  <t>Otherwise this is an error condition.
	  </t>
      </list>
      </t>
      <t>Otherwise if both top level type of second MIME body part is 
         "multipart"
         and 
	 top level type for decoded entity (from body of first MIME 
	 body part) is "multipart", then
	 <list>
	    <t>Generating of body part of decoded
               entity is described on next chapters 
	       ("Decoding of multipart").
	    </t>
	 </list>
      </t>
      <t>Otherwise if both media type of second MIME body part is 
         "message/rfc822" and
          media type for decoded entity (from body of first MIME body part)
	  is "message/rfc822", then
	 <list>
	    <t>A body of second MIME body part is parsed (to header and 
	       body part) and is processed as described on  
	    <xref target="recursive-decod">"Decoding of recursive part"</xref>.
	    Result is copied to body of decoded entity.
	    </t>
	 </list>
      </t>	  
      <t>Otherwise if media type of second MIME body part is 
         "application/octet-stream", then
      <list>
         <t>If encoding for decoded entity (from body of first 
	    MIME body part) is identity (i.e. "content-transfer-encoding"
	    is "7bit", "8bit" or "binary")
	    <list>
	      <t>Body of second MIME body parts forms body part of decoded
                 entity.
	      </t>
	      <t>Encoding (as given on "content-transfer-encoding"
	         header field on second MIME body part) is decoded. 
	      </t>
            </list>
	 </t>
	 <t>If encoding for decoded entity (from body of first 
	    MIME body part) is same than encoding of second MIME body part,
	    <list>
	      <t>Body of second MIME body part forms body part of decoded
                 entity.
	      </t>
	      <t>Encoding is not decoded. </t>
	    </list>	 
	  </t>
	  <t>Otherwise this is an error condition.
	  </t>
      </list>
      </t>
      <t>Otherwise if media type of second MIME body part is same than
         media type for decoded entity (from body of first MIME body part), 
	 then
         <list>
         <t>If encoding for decoded entity (from body of first 
	    MIME body part) is identity (i.e. "content-transfer-encoding"
	    is "7bit", "8bit" or "binary")	    
	    <list>
	      <t>Body of second MIME body part forms body part of decoded
                 entity.
	      </t>
	      <t>Encoding (as given on "content-transfer-encoding"
	         header field on second MIME body part) is decoded. 
	      </t>
	    </list>
	 </t>
	 <t>If encoding for decoded entity (from body of first 
	    MIME body part) is same than encoding of second MIME body part,
	    <list>
	      <t>Body of second MIME body part forms body part of decoded
                 entity.
	      </t>
	      <t>Encoding is not decoded. </t>
	    </list>	 
         </t>
	 <t>Otherwise this is an error condition.
	 <list>
            <t>NOTE: This algorithm do not handle cases where 
	      body part is re-encoded (for example quoted-printable to base64.)
	      Reverse re-enconfig of course is possible, but it does not
	      necessary give exactly same representation.
	    </t>
	 </list>
	 </t>
	 <t>NOTE: This handles unknown media types. 
	    But unknown composite media types was stored as 
	    "application/octet-stream", if they includes non-ASCII characters, 
	    so this handles mostly discrete media types.
	    It is possible that generator of encapsulation
	    knows that type is discrete, but decoder of encapsulation 
	    do not know it.
         </t>
	 </list>
     </t>
      <t>Otherwise this is an error condition.
      </t>      
    </list>
    </t>

    <t>Body of decoded entity is generated following way when
       media type is multipart (both on second MIME body part and
       on decoded entity):
       <list style="numbers">
       <t>A "boundary" parameter value from second MIME body part
          is remembered.
          <list style="symbols">
	    <t>If "boundary" parameter is missing, this is a error 
	       condition.
	    </t>
	  </list>
       </t>
       <t>A "boundary" parameter value from decoded
          entity (from body of first MIME body part) is remembered. 
	  This is new boundary, which is used on
	  generated body of decoded entity.
          <list style="symbols">
	    <t>If a "boundary" parameter is missing, this is a error condition.
	    </t>
	  </list>
       </t>
       <t>A "preamble" area from body of second MIME body part is copied
          to body of decoded entity. 
          <list style="symbols">
          <t>It is not an error condition on
	     decoding if "preamble" area includes non-ASCII characters.
	  </t>
	  </list>
       </t>
       <t>Body parts of multipart (from body of second MIME body part) are 
          handled:
       <list>
          <t>A boundary delimiter line is copied
             to body of decoded entity, but that way that 
             boundary of second MIME body part is replaced with
	     boundary of decoded entity.
	  </t>
	  <t>A body part is parsed (to header and body part) and is 
	    processed as described on  
	    <xref target="recursive-decod">"Decoding of recursive part"</xref>.
	    Result is copied to body of decoded entity.
	  </t>
       </list>
       </t>
       <t>A final boundary delimiter line is copied
          to body of decoded entity, but that way that 
          boundary of second MIME body part is replaced with
	  boundary of decoded entity.
         <list style="symbols">
         <t>A final final boundary delimiter line is not generated to
           decoded entity if final boundary delimiter 
	   line is missing on second MIME body part.
	   This is not an error condition on decoding.
         </t>
	 </list>
       </t>
       <t>An "epilogue" area from body of second MIME body part is copied
          to body of decoded entity. 
          <list style="symbols">
          <t>It is not an error condition on
	     decoding if "epilogue" area includes non-ASCII characters.
	  </t>
	  </list>
       </t>
       </list>
    </t>

    <t>
    <list style="hanging">
      <t hangText="NOTE:">The CRLF preceding the boundary delimiter line
      is conceptually attached to the boundary (as per <xref target="RFC2046" />). 
      That CRLF is not part of body part of multipart. 
      </t>
    </list>
    </t>

       <section anchor="recursive-decod" title="Decoding of recursive part">

       <t>Decoding of recursive part is done following way:
       <list style="numbers">
         <t>If media type of recursive part is 
	    "multipart/utf8-encapsulated" and "type" parameter 
	    is "part" as value:
	    <list>
	    <t>Recursive part is considered to be "encapsulating
	       entity" and <xref target="generic-decod">"Generic decoding"</xref> 
	       is applied.
	    </t>
	    <t>Resulting decoded entity is result
	       for "Decoding of recursive part".
	    </t>
	    </list>
	 </t>
	 <t>If media type of recursive part is discrete,
	    result for "Decoding of recursive part" 
	    is recursive part itself.
	 </t>
	 <t>Otherwise if media type of recursive part is "message/rfc822",
	     then
            <list style="symbols">
	    <t>Header part of result for 
               "Decoding of recursive part" result,
	       is header part of recursive part.
	    </t>
	    <t>Body part of recursive part is parsed 
               (to header and body part)
               and is processed as described on  
	       <xref target="recursive-decod">"Decoding of recursive part"</xref>.
	       Body part of result for 
	       "Decoding of recursive part" 
	       is result of processing.
	    </t>
	    </list>
	 </t>
         <t>Otherwise if top level type of recursive part is
	     multipart (i.e. media type is multipart/*) and
	     "boundary" parameter exists,
	     handling of it is described on next chapter.
	    <list style="symbols">
	    <t>Missing "boundary" parameter on multipart types 
	       is not error condition on decoding.
	    </t>
	    </list>
         </t>

	  <t>Otherwise if recursive part is ASCII only 
	     and encoding of recursive part 
	     is identity (i.e. "content-transfer-encoding"
	                  is "7bit", "8bit" or "binary")	    
             result for "Decoding of recursive part" 
	     is recursive part itself.
          </t>
	  <t>Otherwise this is error condition.
            <list style="symbols">
	    <t>NOTE: This means that missing 
	             "boundary" parameter is error condition
		     for decoding if body is not ASCII only
		     (or required encoding).
	    </t>
	    <t>NOTE: This means that unknown composite
	             types is error condition, if body is 
		     not ASCII only (or required encoding).
	    </t>
	    </list>
	  </t>

       </list>
       </t>


       <t>If top level type is multipart,
          result for "Decoding of recursive part"
	  is generated following way:
	  <list style="numbers">
	    <t>Header part of result for 
               "Decoding of recursive part" result,
	       is header part of recursive part.
	    </t>
            <t>A "boundary" parameter value from recursive part is 
	       remembered.
              <list style="symbols">
              <t>Handling of missing "boundary" parameter is described on 
	         previous chapters.</t>
              </list>
            </t>
	    <t>Body part for "Decoding of recursive part" result
	       is initiated.
	    </t>
	    <t>A "preamble" area from body of recursive part is copied
		   to body part for "Decoding of recursive part" result.
                <list style="symbols">
                <t>It is not an error condition on
	           decoding if "preamble" area includes non-ASCII characters.
	        </t>
                </list>
	    </t>
	    <t>Body parts of multipart (from body of recursive part) are handled:
	    <list>
	       <t>A boundary delimiter line is copied
	          to body part for "Decoding of recursive part" result.
	       </t>
	       <t>A body part is parsed (to header and body part) and is 
	          processed as described on  
		   <xref target="recursive-decod">"Decoding of recursive part"</xref>.
		  Result is copied to 
		  body part for "Decoding of recursive part" result.
	       </t>
            </list>
	    </t>
            <t>A final boundary delimiter line is copied 
	       (from body of recursive part) to 
	       body part for "Decoding of recursive part" result.
	       <list style="symbols">
	       <t>A final final boundary delimiter line is not generated to
                  body part for "Decoding of recursive part" result 
		  if final boundary delimiter 
		  line is missing on second MIME body part.
		  This is not an error condition on decoding.
	       </t>
	       </list>
	    </t>
	    <t>An "epilogue" area from body of recursive part is copied
	       to body part for "Decoding of recursive part" 
	       result.
	       <list style="symbols">
	       <t>It is not an error condition on
	          decoding if "epilogue" area includes non-ASCII characters.
	       </t>
	       </list>
	    </t>
	  </list>
       </t>

       </section>


    </section>

    <section anchor="upgrade-email" 
      title="Upgrading of internationalized email message">

    <t>When downgraded internationalized email enters  EAI 
       compliant environment upgrade is allowed. 
       <xref target="ietf-eai-downgrade" /> describes  when upgrade 
       occurs.
    </t>

    <t>This document defines "Encapsulated" value to
       "Downgrade-Method" header field. "Header-Type" header field
       defines how upgrade occurs.

       <list style="symbols">
        <t>If header field "Downgraded" exits, 
	   upgrading of header part (and body) of mail is done according of 
	    <xref target="ietf-eai-downgrade" />.
	</t>
	<t>If header field "Downgrade-Method" exists with value is "Encapsulated",
	   upgrading  of header
	    part (and body) of mail is done as described on this section.
         </t>
        <t>If both header field "Downgraded" and "Downgrade-Method" exists,
           this is error condition and upgrading is not node.
        </t>
        </list>
    </t>

    <t>Encapsulating entity is not decoded
       on error conditions.
       Instead original encapsulating entity is returned.
    </t>

     <t>Upgrading of internationalized email is done following way:
     <list style="symbols">
     <t>If media type of downgraded internationalized email is not
        "multipart/utf8-encapsulated" or if 
	parameter "type" have not "encapsulated" as value,
	this is a error condition.
     </t>
     <t>Downgraded internationalized email is considered to be
        "encapsulating entity" and 
	<xref target="generic-decod">"Generic decoding"</xref>
	is applied.
     </t>
     <t>Resulting decoded internationalized entity
        is upgraded internationalized email.
     </t>
     <t>"Received" header fields from 
        downgraded internationalized are prepended
	to upgraded internationalized email.
	<list style="symbols">
	<t>Upgraded internationalized email already includes all
	   original header fields. This adds trace header fields
	   which are inserted to mail after it was downgrading.
	   This do not re-add trace header fields which was 
	   added before downgrading,
	   because them are renamed to "I18N-Received" on downgraded
	   internationalized email.
	</t>
	</list>
     </t>
     </list>
     </t>


       

       <section title="Upgrading example">

      <figure>
        <preamble>
	An upgrading example of mail from 
	<xref target="encap-mail-mail">earlier example</xref>
	is used. Mail is assumed 8BITMIME
	downgraded afterwards. This process was added also some 
	extra header fields to mime parts.
	</preamble>

<artwork>

    Downgraded internationalized email:

    ==========================================
    Received: from fw.example.org
        by upgrade.example.org with ESMTP 
        id JAX77356; 
        Wed, 13 Sep 2006 22:27:32 +0300
    Received: from downgrade.example.org
        by fw.example.org with ESMTP 
        id JAX77356; 
        Wed, 13 Sep 2006 22:27:29 +0300
    I18N-Received: from {idn-encoded-name} 
        by downgrade.example.org with ESMTP 
        id JGR17356; 
        Wed, 13 Sep 2006 22:27:25 +0300
    Downgrade-Method: Encapsulated
    From: { downgraded address }
    To: someone@example.org
    Date: Wed, 13 Sep 2006 22:27:25 +0300
    Subject: { RFC 2047 encoded subject }
    Mime-Version: 1.0
    Content-Type: multipart/utf8-encapsulated; 
      type=encapsulated; boundary="12345"
    Content-Transfer-Encoding: 7bit


    --12345
    Content-Type: text/utf8-header; charset=UTF-8
    Content-Transfer-Encoding: quoted-printable
    X-MIME-Autoconverted: from 8bit to quoted-printable 
        by downgrade.example.org id JGR17356

    Received: from {idn-encoded-name}
        by downgrade.example.org with ESMTP
        id JGR17356;
        Wed, 13 Sep 2006 22:27:25 +0300
    Downgrade-Method: encapsulate
    From: { q-p encoded UTF-8 address }
    To: someone@example.org
    Date: Wed, 13 Sep 2006 22:27:25 +0300
    Subject: { q-p encoded UTF-8 subject }
    X-Foobar: XvrT
    Mime-Version: 1.0
    Content-Type: Text/plain; charset=3DUTF-8
    Content-Transfer-Encoding: 8bit

    --12345
    Content-Type: Text/plain; charset=UTF-8
    Content-Transfer-Encoding: quoted-printable
    X-MIME-Autoconverted: from 8bit to quoted-printable 
        by downgrade.example.org id JGR17356

    { q-p encoded UTF-8 text }

    --12345--
    ==========================================

    Upgraded internationalized email:

    ==========================================
    Received: from fw.example.org
        by upgrade.example.org with ESMTP 
        id JAX77356; 
        Wed, 13 Sep 2006 22:27:32 +0300
    Received: from downgrade.example.org
        by fw.example.org with ESMTP 
        id JAX77356; 
        Wed, 13 Sep 2006 22:27:29 +0300
    Received: from {idn-encoded-name}
        by downgrade.example.org with ESMTP
        id JGR17356;
        Wed, 13 Sep 2006 22:27:25 +0300
    Downgrade-Method: encapsulate
    From: { UTF-8 address }
    To: someone@example.org
    Date: Wed, 13 Sep 2006 22:27:25 +0300
    Subject: { UTF-8 subject }
    X-Foobar: XvrT
    Mime-Version: 1.0
    Content-Type: Text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit

    { UTF-8 text }
    ==========================================


</artwork>

        <postamble>
	Note handling of Received: header fields.
	That is only header field what was preserved
	from downgraded internationalized email. All 
	other header fields are got from "text/utf8-header"
	MIME part. This also means that upgrading do not
	need add "Header-Type" header field, because it
	necessary already on "text/utf8-header" 
	MIME part. On downgraded e-mail there was empty
	line after "UTF-8 text", but on upgraded email
	it is disappeared because it was part of
	multipart boundary.
	</postamble>


      </figure>

       </section>



    </section>

    <section title="Retrieving attached internationalized email message">

    <t>"Multipart/utf8-encapsulated" with "type"
       parameter value "message" can be used to attach internationalized 
       email messages on EAI non-compliant environments.</t>

    
    <t>Retrieving internationalized email can be done 
       following way:
       <list style="symbols">
       <t>If media type is "message/rfc822", 
          then
	  <list>
	     <t>It is parsed (to header and body part). 
	     </t>
	     <t>Body part is processed as described 
	        <xref target="upgrade-email">"Upgrading of internationalized email message"</xref>
	     </t>
	     <t>Result is internationalized email.
             </t>	        
	  </list>
       </t>
       <t>If media type is "Multipart/utf8-encapsulated"
          and parameter "type" value is "message",
	  then
	  <list>
	  <t>It is considered  to be
             "encapsulating entity" and 
	     <xref target="generic-decod">"Generic decoding"</xref>
	     is applied.
	  </t>
	  <t>Result is internationalized email.
	  </t>
	  </list>
       </t>
       </list>
    </t>

    </section>

    </section>


    <section title="IANA Considerations">

    <t>
     IANA is requested to register I18N-Received and Downgrade-Method 
     header fields
     and multipart/utf8-encapsulated and text/utf8-header media types
     as given on registration applications on this document.
    </t>

    </section>

    <section title="Security Considerations">

<t>
This "multipart/utf8-encapsulated" media type provides method to 
encapsulate mail data. Specially this media type provides method to 
smuggle mail header fields so that mail scanners
do not see them. This may provide new security threats.
</t>                                   
<t>
This encapsulation do not hide original MIME parts. However original MIME 
structure may be obscured. This may provide method to smuggle MIME parts
so that mail scanners do not see them. This may provide new security threats.
</t>
<t>
This encapsulation preservers only "Received" header fields from 
encapsulating message. This may hide information when encapsulated 
message is upgraded to internationalized email format.
</t>

    </section>

    <section title="Acknowledgements">

    <t>Originally this encapsulation format is suggested on former IMAA 
       mailing list discussions. </t>

    <t>Various ideas are suggested on IMA mailing list
       discussions. </t>

    <t>John C. Klensin was strongly encouraging author to write this
       documentation.
     </t>


    </section>


   </middle>


   <back>


<!--                                   -->


<references title="Normative References">

<reference anchor='ASCII'>
        <front>
          <title>USA Code for Information Interchange</title>
          <author>
            <organization abbrev="ANSI">
              American National Standards Institute
                (formerly United States of America Standards Institute)
	    </organization>
          </author>
          <date year="1968"/>
        </front>
      <seriesInfo name="ANSI" value="X3.4-1968" />
      <annotation>ANSI X3.4-1968 has been replaced by newer
	  versions with slight modifications, but the 1968 version
	  remains definitive for the Internet. </annotation>
 </reference>


 <reference anchor="ietf-eai-framework">
    <front>
        <title>
        Overview and Framework for Internationalized Email
        </title>
        <author initials="J.C.K." surname="Klensin" fullname="John C Klensin">
            <organization /></author>
        <author initials="Y.W.K." surname="Ko" fullname="YangWoo Ko">
            <organization /></author>
        <date month="February" day="5" year="2007" />
    </front>

    <seriesInfo name="Internet-Draft" value="draft-ietf-eai-framework-05" />
</reference>

<reference anchor="ietf-eai-downgrade">
     <front>
     <title>
     Downgrading mechanism for Email Address Internationalization
     </title>
     <author initials="Y.Y." surname="YONEYA" fullname="Yoshiro YONEYA"
       role="editor">
        <organization> JPRS </organization> 
     </author>
     <author initials="K.F." surname="Fujiwara" fullname="Kazunori Fujiwara"
       role="editor">
        <organization> JPRS </organization> 
     </author>
     <date month="March" day="5" year="2007" />
     </front>
   <seriesInfo name="Internet-Draft" value="draft-ietf-eai-downgrade-03"/>

</reference>
 
<reference anchor="ietf-eai-utf8headers">
    <front>
      <title>
      Internationalized Email Headers
      </title>
      <author initials="J.Y." surname="Yeh" fullname="Jeff YEH" role="editor">
            <organization>TWNIC</organization>
      </author>
      <author           surname="Abel" fullname="Abel Yang" role="editor">
            <organization>TWNIC</organization>
      </author>
    <date month="March" day="4"  year="2007" />
    </front>
    <seriesInfo name="Internet-Draft" value="draft-ietf-eai-utf8headers-04"/>
</reference>

<reference anchor='RFC2045'>
  <front>
  <title>Multipurpose Internet Mail Extensions (MIME) Part One:
          Format of Internet Message Bodies
  </title>
  <author initials="N.F." surname='Freed' fullname='Ned Freed'>
            <organization /></author>
  <author initials="N.S.B." surname="Borenstein" 
       fullname='Nathaniel S. Borenstein'>
            <organization /></author>
  <date month="November" year="1996" />  
  </front>
  <seriesInfo name='RFC' value='2045' />
</reference>

<reference anchor='RFC2046'>
  <front>
  <title>Multipurpose Internet Mail Extensions (MIME) Part Two:
         Media Types
  </title>
  <author initials="N.F." surname='Freed' fullname='Ned Freed'>
            <organization /></author>
  <author initials="N.S.B." surname="Borenstein" 
      fullname='Nathaniel S. Borenstein'>
            <organization /></author>
  <date month="November" year="1996" />  
  </front>
  <seriesInfo name='RFC' value='2046' />
</reference>

<reference anchor='RFC2047'>
  <front>
  <title>Multipurpose Internet Mail Extensions (MIME) Part Three:
         Message Header Extensions for Non-ASCII Text
  </title>
  <author initials="K.M." surname='Moore' fullname='Keith Moore'>
            <organization /></author>
   <date month="November" year="1996" />  
  </front>
  <seriesInfo name='RFC' value='2047' />
</reference>

<reference anchor='RFC2822'>
  <front>
  <title>Internet Message Format</title>
  <author initials='P.R.' surname='Resnick' fullname='P. Resnick'>
            <organization /></author>
  <date month='April' year='2001' />
  </front>
  <seriesInfo name='RFC' value='2822' />
</reference>
   
<reference anchor="RFC2231">
  <front>
  <title>
  MIME Parameter Value and Encoded Word Extensions:
  Character Sets, Languages, and Continuations
  </title>
  <author initials="N.F." surname='Freed' fullname='Ned Freed'>
            <organization /></author>
  <author initials="K.M." surname='Moore' fullname='Keith Moore'>
            <organization /></author>
  <date month='November' year='1997' />
  </front>
  <seriesInfo name='RFC' value='2231' />
</reference>

<reference anchor="RFC3629">
  <front>
  <title>
  UTF-8, a transformation format of ISO 10646
  </title>
  <author initials="F.Y." surname="Yergeau" fullname="Francois Yergeau">
            <organization /></author>
  <date month="November" year="2003" />
  </front>
  <seriesInfo name='RFC' value='3629' />
</reference>

</references>


<!--                                   -->

<references title="Informative References">

<reference anchor="DKIM-Charter"
                   target="http://www.ietf.org/html.charters/dkim-charter.html">
   <front>
          <title>Domain Keys Identified Mail (dkim)</title>
          <author>
          <organization>IETF</organization>
          </author>
          <date year="2006" month="October" day="4"/>
   </front>
</reference>

<!--
<reference anchor="ietf-eai-smtpext">
    <front>
      <title>
        SMTP extension for internationalized email address
      </title>
      <author role="editor" initials="J.K.Y." surname="Yao" fullname="Jiankang YAO">
         <organization>CNNIC</organization>
      </author>
      <author role="editor" initials="W.M." surname="Mao" fullname="MAO Wei">
        <organization> CNNIC</organization>
      </author>
       <date month="March" day="3"  year="2007" />
    </front>
    <seriesInfo name="Internet-Draft" value="draft-ietf-eai-smtpext-04"/>
</reference>
-->


<reference anchor="RFC1847">
   <front>
   <title>Security Multiparts for MIME:
          Multipart/Signed and Multipart/Encrypted
   </title>
   <author initials="J.G." surname="Galvin" fullname="Jim Galvin">
            <organization /></author>
   <author initials="S.M." surname="Murphy" fullname="Sandy Murphy">
            <organization /></author>
   <author initials="S.C." surname="Crocker" fullname="Steve Crocker">
            <organization /></author>
   <author initials="N.F." surname="Freed" fullname="Ned Freed">
            <organization /></author>
   <date month="October" year="1995" />     
   </front>
   <seriesInfo name='RFC' value='1847' />

</reference>

<reference anchor="RFC1652">
  <front>
  <title>SMTP Service Extension for 8bit-MIMEtransport</title>
  <author initials="N.F." surname="Freed" fullname="Ned Freed" role="editor">
            <organization /></author>
  <author initials="M.T.R." surname="Rose" fullname="Marshall T. Rose">
            <organization /></author>
  <author initials="E.A.S." surname="Stefferud" fullname="Einar A. Stefferud">
            <organization /></author>
  <author initials="D.C." surname="Crocker" fullname="Dave Crocker">
            <organization /></author>
  <date month="July" year="1994" />  
  </front>
  <seriesInfo name='RFC' value='1652' />
</reference>

<reference anchor="RFC4288">
  <front>
  <title>Media Type Specifications and Registration Procedures</title>
  <author initials="N.F." surname="Freed" fullname="Ned Freed">
            <organization /></author>
  <author initials="J.C.K." surname="Klensin" fullname="John C Klensin">
            <organization /></author>
  <date month="December" year="2005" />
  </front>
  <seriesInfo name='RFC' value='4288' />
  <seriesInfo name='BCP' value='13' />

</reference>

<reference anchor="RFC3864">
  <front>
  <title>Registration Procedures for Message Header Fields</title>
  <author initials="G.K." surname="Klyne" fullname="Graham Klyne">
            <organization /></author>
  <author initials="M.N." surname="Nottingham" fullname="Mark Nottingham">
            <organization /></author>
  <author initials="J.C.M." surname="Mogul" fullname="Jeffrey C. Mogul">
            <organization /></author>
  <date month="September" year="2004" />
  </front>
  <seriesInfo name='RFC' value='3864' />
  <seriesInfo name='BCP' value='90' />

</reference>


   </references>



   </back>


</rfc>
