From user@domain  Fri Feb 22 17:06:23 2008
From: user@domain.org
Date: Sat, 24 Mar 2007 23:00:00 +0200
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="foo bar"

Root MIME prologue

--foo bar
Content-Type: text/x-myown; charset=us-ascii

hello

--foo bar
Content-Type: message/rfc822

From: sub@domain.org
Date: Sun, 12 Aug 2012 12:34:56 +0300
Subject: submsg
Content-Type: multipart/alternative; boundary="sub1"

Sub MIME prologue
--sub1
Content-Type: text/html

<p>Hello world</p>

--sub1
Content-Type: multipart/alternative; boundary="sub2"

--sub2
Content-Type: multipart/alternative; boundary="sub3"

--sub3

sub3 text
--sub3

sub3 text2
--sub3--

sub2 text
--sub2

sub2 text2
--sub2--
--sub1--
Sub MIME epilogue

--foo bar
Content-Type: text/plain

Another part
--foo bar--
Root MIME epilogue


---- EXPECTED STRUCTURE ----
{
  "headers_rfc": {
    "from": {
      "Address": {
        "name": null,
        "address": "user@domain.org"
      }
    },
    "content_type": {
      "ContentType": {
        "c_type": "multipart",
        "c_subtype": "mixed",
        "attributes": {
          "boundary": "foo bar"
        }
      }
    },
    "date": {
      "DateTime": {
        "year": 2007,
        "month": 3,
        "day": 24,
        "hour": 23,
        "minute": 0,
        "second": 0,
        "tz_before_gmt": false,
        "tz_hour": 2,
        "tz_minute": 0
      }
    },
    "mime_version": {
      "Text": "1.0"
    }
  },
  "headers_other": {
    "From user@domain  Fri Feb 22 17": {
      "Text": "06:23 2008"
    }
  },
  "headers_offsets": [
    {
      "name": {
        "Other": "From user@domain  Fri Feb 22 17"
      },
      "start": 32,
      "end": 43
    },
    {
      "name": {
        "Rfc": "from"
      },
      "start": 48,
      "end": 65
    },
    {
      "name": {
        "Rfc": "date"
      },
      "start": 70,
      "end": 103
    },
    {
      "name": {
        "Rfc": "mime_version"
      },
      "start": 116,
      "end": 121
    },
    {
      "name": {
        "Rfc": "content_type"
      },
      "start": 134,
      "end": 171
    }
  ],
  "html_body": [
    2
  ],
  "text_body": [
    2
  ],
  "attachments": [
    0,
    1
  ],
  "parts": [
    {
      "Text": {
        "headers": {
          "content_type": {
            "ContentType": {
              "c_type": "text",
              "c_subtype": "x-myown",
              "attributes": {
                "charset": "us-ascii"
              }
            }
          }
        },
        "body": "hello\n"
      }
    },
    {
      "Message": {
        "headers": {
          "content_type": {
            "ContentType": {
              "c_type": "message",
              "c_subtype": "rfc822",
              "attributes": null
            }
          }
        },
        "body": {
          "headers_rfc": {
            "subject": {
              "Text": "submsg"
            },
            "content_type": {
              "ContentType": {
                "c_type": "multipart",
                "c_subtype": "alternative",
                "attributes": {
                  "boundary": "sub1"
                }
              }
            },
            "from": {
              "Address": {
                "name": null,
                "address": "sub@domain.org"
              }
            },
            "date": {
              "DateTime": {
                "year": 2012,
                "month": 8,
                "day": 12,
                "hour": 12,
                "minute": 34,
                "second": 56,
                "tz_before_gmt": false,
                "tz_hour": 3,
                "tz_minute": 0
              }
            }
          },
          "headers_other": {},
          "headers_offsets": [
            {
              "name": {
                "Rfc": "from"
              },
              "start": 300,
              "end": 316
            },
            {
              "name": {
                "Rfc": "date"
              },
              "start": 321,
              "end": 354
            },
            {
              "name": {
                "Rfc": "subject"
              },
              "start": 362,
              "end": 370
            },
            {
              "name": {
                "Rfc": "content_type"
              },
              "start": 383,
              "end": 423
            }
          ],
          "html_body": [
            0,
            4
          ],
          "text_body": [
            3,
            4,
            5
          ],
          "attachments": [],
          "parts": [
            {
              "Html": {
                "headers": {
                  "content_type": {
                    "ContentType": {
                      "c_type": "text",
                      "c_subtype": "html",
                      "attributes": null
                    }
                  }
                },
                "body": "<p>Hello world</p>\n"
              }
            },
            {
              "Multipart": {
                "content_type": {
                  "ContentType": {
                    "c_type": "multipart",
                    "c_subtype": "alternative",
                    "attributes": {
                      "boundary": "sub2"
                    }
                  }
                }
              }
            },
            {
              "Multipart": {
                "content_type": {
                  "ContentType": {
                    "c_type": "multipart",
                    "c_subtype": "alternative",
                    "attributes": {
                      "boundary": "sub3"
                    }
                  }
                }
              }
            },
            {
              "Text": {
                "headers": {},
                "body": "sub3 text"
              }
            },
            {
              "Text": {
                "headers": {},
                "body": "sub3 text2"
              }
            },
            {
              "Text": {
                "headers": {},
                "body": "sub2 text2"
              }
            }
          ],
          "structure": {
            "List": [
              {
                "Part": 0
              },
              {
                "MultiPart": [
                  1,
                  [
                    {
                      "MultiPart": [
                        2,
                        [
                          {
                            "Part": 3
                          },
                          {
                            "Part": 4
                          }
                        ]
                      ]
                    },
                    {
                      "Part": 5
                    }
                  ]
                ]
              }
            ]
          },
          "offset_header": 295,
          "offset_body": 424,
          "offset_end": 710
        }
      }
    },
    {
      "Text": {
        "headers": {
          "content_type": {
            "ContentType": {
              "c_type": "text",
              "c_subtype": "plain",
              "attributes": null
            }
          }
        },
        "body": "Another part"
      }
    }
  ],
  "structure": {
    "List": [
      {
        "Part": 0
      },
      {
        "Part": 1
      },
      {
        "Part": 2
      }
    ]
  },
  "offset_header": 0,
  "offset_body": 172,
  "offset_end": 789
}