Nested Body Parts

Multipart messages are themselves nested. Nesting body parts is similar. This type of nesting can be very useful if you want to forward an email message, for example, that has attachments itself.

Look carefully at the Content-Type headers in the following example. There are six of them! The one on the message header is a composite type (multipart/mixed), allowing it to have message parts under it. One of the parts is a simple text message, and the other is a complete mail message.

The encapsulated mail message itself has an outer wrapper, a message-level Content-Type header that is declared as type message/rfc822, another composite type. In turn, it holds a text message and an image from a previous example.

From:  Al Gore <[email protected]>
To:  White House Transportation Coordinator
     <[email protected]>
Subject: [Fwd: Map of Argentina with Description]
Content-Type: multipart/mixed;
              boundary="D7F------------D7FD5A0B8AB9C65CCDBFA872"

This is a multi-part message in MIME format.
--D7F------------D7FD5A0B8AB9C65CCDBFA872
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Fred,

Fire up Air Force One!  We're going South!

Thanks,
Al
--D7F------------D7FD5A0B8AB9C65CCDBFA872
Content-Type: message/rfc822
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Return-Path: <[email protected]>
Received: from mailhost.whitehouse.gov ([192.168.51.200])
        by heartbeat.whitehouse.gov (8.8.8/8.8.8) with ESMTP id SAA22453
        for <[email protected]>;
        Mon, 13 Aug 1998 l8:14:23 +1000
Received: from the_big_box.whitehouse.gov ([192.168.51.50])
        by mailhost.whitehouse.gov (8.8.8/8.8.7) with ESMTP id RAA20366
        for [email protected]; Mon, 13 Aug 1998 17:42:41 +1000
Date: Mon, 13 Aug 1998 17:42:41 +1000
Message-Id: <[email protected]>
From: Bill Clinton <[email protected]>
To: A1 (The Enforcer) Gore <[email protected]>
Subject:  Map of Argentina with Description
MIME-Version: 1.0
Content-Type: multipart/mixed;
              boundary="DC8------------DC8638F443D87A7F0726DEF7"

This is a multi-part message in MIME format.
--DC8------------DC8638F443D87A7F0726DEF7
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi A1,

I finally figured out this MIME thing.  Pretty cool.  I'll send you
some sax music in .au files next week!

Anyway, the attached image is really too small to get a good look at
Argentina.  Try this for a much better map:

     http://www.1one1yp1anet.com/dest/sam/graphics/map-arg.htm

Then again, shouldn't the CIA have something like that?

Bill
--DC8------------DC8638F443D87A7F0726DEF7
Content-Type: image/gif; name="map_of_Argentina.gif"
Content-Transfer-Encoding: base64
Content-Disposition: in1ine; fi1ename="map_of_Argentina.gif"

R01GOD1hJQA1AKIAAP/////78P/omn19fQAAAAAAAAAAAAAAACwAAAAAJQA1AAAD7Qi63P5w
wEmjBCLrnQnhYCgM1wh+pkgqqeC9XrutmBm7hAK3tP31gFcAiFKVQrGFR6kscnonTe7FAAad
GugmRu3CmiBt57fsVq3Y0VFKnpYdxPC6M7Ze4crnnHum4oN6LFJ1bn5NXTN7OF5fQkN5WYow
BEN2dkGQGWJtSzqGTICJgnQuTJN/WJsojad9qXMuhIWdjXKjY4tenjo6tjVssk2gaWq3uGNX
U6ZGxseyk8SasGw3J9GRzdTQky1iHNvcPNNI4TLeKdfMvy0vMqLrItvuxfDW8ubjueDtJufz
7itICBxISKDBgwgTKjyYAAA7
--DC8------------DC8638F443D87A7F0726DEF7--

--D7F------------D7FD5A0B8AB9C65CCDBFA872--

The most important thing to note with nested body parts is that there may be multiple MIME boundaries. When parsing these messages, you will need to keep track of which set of message parts you are working on.

As with any nested body part messages, note the following:

  • The outer message has a composite Content-Type header; in this case it is multipart/mixed. This header gives the first MIME boundary as a parameter (the one starting with D7F).

  • The body of the outer message begins with the same plain text warning message about the rest of the message being in MIME format.

  • Each message part of the outer message is bracketed by the outer message’s appended MIME boundary (the D7F boundary, preceded by two start-of-line hyphens).

  • The forwarded message (we’ll call it the “inner message” in this example) is synonymous with the outer message’s second body part. Therefore, it is bracketed with the appended “D7F” boundary markers.

  • The inner message has a composite Content-Type header of message/rfc822, since it is an email message. If it were not a message but still had multiple parts, it would be multipart/mixed. Note that this is in the MIME part headers for the outer message! This is where the outer message is told about the content of its second message part, the inner message.

  • Since the inner message has passed through the mail system and undergone an initial delivery, its message headers have expanded; MTAs along the way have added the required Return-Path, Received, Date, and Message-ID headers for message tracing and accountability as described in Chapter 2, Simple Text Messages, and Chapter 9, The Extended Simple Mail Transfer Protocol.

  • The inner message has its own message headers, including an outer Content-Type header with its own MIME boundary marker (the one starting with DC8). The rest of the message is exactly as it appeared in the previous example.

  • The end of the message shows two MIME boundaries, since the attached inner message is the last body part in the outer message. The appended DC8 boundary ends with two hyphens (--) to indicate that its scope is complete. Any use of the “DC8” marker beyond this point would be incorrect and confusing. The last item in the outer message is its MIME boundary (D7F), also ending with two hyphens, denoting its end of scope. These marks produce a clear indication of scope changes to parsers.

There is no limit to the amount of nesting that may take place. Messages may contain messages that contain messages, ad nauseam.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.6.194