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": {
    "values": {
      "mime_version": {
        "Text": "1.0"
      },
      "date": {
        "DateTime": {
          "year": 2007,
          "month": 3,
          "day": 24,
          "hour": 23,
          "minute": 0,
          "second": 0,
          "tz_before_gmt": false,
          "tz_hour": 2,
          "tz_minute": 0
        }
      },
      "content_type": {
        "ContentType": {
          "c_type": "multipart",
          "c_subtype": "mixed",
          "attributes": {
            "boundary": "foo bar"
          }
        }
      },
      "from": {
        "Address": {
          "address": "user@domain.org"
        }
      }
    },
    "other_values": {
      "From user@domain  Fri Feb 22 17": {
        "Text": "06:23 2008"
      }
    },
    "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": [
    3
  ],
  "text_body": [
    3
  ],
  "attachments": [
    {
      "Attachment": 0
    },
    {
      "Attachment": 2
    }
  ],
  "parts": [
    {
      "Text": {
        "headers": {
          "values": {
            "content_type": {
              "ContentType": {
                "c_type": "text",
                "c_subtype": "x-myown",
                "attributes": {
                  "charset": "us-ascii"
                }
              }
            }
          },
          "offsets": [
            {
              "name": {
                "Rfc": "content_type"
              },
              "start": 215,
              "end": 247
            }
          ]
        },
        "contents": "hello\n",
        "is_html": false
      }
    },
    {
      "Multipart": {
        "values": {
          "content_type": {
            "ContentType": {
              "c_type": "message",
              "c_subtype": "rfc822"
            }
          }
        },
        "offsets": [
          {
            "name": {
              "Rfc": "content_type"
            },
            "start": 278,
            "end": 294
          }
        ]
      }
    },
    {
      "Message": {
        "headers": {
          "values": {
            "subject": {
              "Text": "submsg"
            },
            "from": {
              "Address": {
                "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
              }
            },
            "content_type": {
              "ContentType": {
                "c_type": "multipart",
                "c_subtype": "alternative",
                "attributes": {
                  "boundary": "sub1"
                }
              }
            }
          },
          "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
        ],
        "parts": [
          {
            "Text": {
              "headers": {
                "values": {
                  "content_type": {
                    "ContentType": {
                      "c_type": "text",
                      "c_subtype": "html"
                    }
                  }
                },
                "offsets": [
                  {
                    "name": {
                      "Rfc": "content_type"
                    },
                    "start": 462,
                    "end": 473
                  }
                ]
              },
              "contents": "<p>Hello world</p>\n",
              "is_html": true
            }
          },
          {
            "Multipart": {
              "values": {
                "content_type": {
                  "ContentType": {
                    "c_type": "multipart",
                    "c_subtype": "alternative",
                    "attributes": {
                      "boundary": "sub2"
                    }
                  }
                }
              },
              "offsets": [
                {
                  "name": {
                    "Rfc": "content_type"
                  },
                  "start": 514,
                  "end": 554
                }
              ]
            }
          },
          {
            "Multipart": {
              "values": {
                "content_type": {
                  "ContentType": {
                    "c_type": "multipart",
                    "c_subtype": "alternative",
                    "attributes": {
                      "boundary": "sub3"
                    }
                  }
                }
              },
              "offsets": [
                {
                  "name": {
                    "Rfc": "content_type"
                  },
                  "start": 575,
                  "end": 615
                }
              ]
            }
          },
          {
            "Text": {
              "contents": "sub3 text",
              "is_html": false
            }
          },
          {
            "Text": {
              "contents": "sub3 text2",
              "is_html": false
            }
          },
          {
            "Text": {
              "contents": "sub2 text2",
              "is_html": false
            }
          }
        ],
        "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": {
          "values": {
            "content_type": {
              "ContentType": {
                "c_type": "text",
                "c_subtype": "plain"
              }
            }
          },
          "offsets": [
            {
              "name": {
                "Rfc": "content_type"
              },
              "start": 752,
              "end": 764
            }
          ]
        },
        "contents": "Another part",
        "is_html": false
      }
    }
  ],
  "structure": {
    "List": [
      {
        "Part": 0
      },
      {
        "Part": 1
      },
      {
        "Part": 3
      }
    ]
  },
  "offset_header": 0,
  "offset_body": 172,
  "offset_end": 789
}