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 ----{
  "html_body": [
    3
  ],
  "text_body": [
    3
  ],
  "attachments": [
    1,
    2
  ],
  "parts": [
    {
      "headers_rfc": {
        "from": {
          "Address": {
            "name": null,
            "address": "user@domain.org"
          }
        },
        "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"
        },
        "content_type": {
          "ContentType": {
            "c_type": "multipart",
            "c_subtype": "mixed",
            "attributes": {
              "boundary": "foo bar"
            }
          }
        }
      },
      "headers_raw": [
        [
          {
            "Other": "From user@domain  Fri Feb 22 17"
          },
          {
            "start": 32,
            "end": 43
          }
        ],
        [
          {
            "Rfc": "from"
          },
          {
            "start": 48,
            "end": 65
          }
        ],
        [
          {
            "Rfc": "date"
          },
          {
            "start": 70,
            "end": 103
          }
        ],
        [
          {
            "Rfc": "mime_version"
          },
          {
            "start": 116,
            "end": 121
          }
        ],
        [
          {
            "Rfc": "content_type"
          },
          {
            "start": 134,
            "end": 171
          }
        ]
      ],
      "is_encoding_problem": false,
      "body": {
        "Multipart": [
          1,
          2,
          3
        ]
      },
      "offset_header": 0,
      "offset_body": 172,
      "offset_end": 790
    },
    {
      "headers_rfc": {
        "content_type": {
          "ContentType": {
            "c_type": "text",
            "c_subtype": "x-myown",
            "attributes": {
              "charset": "us-ascii"
            }
          }
        }
      },
      "headers_raw": [
        [
          {
            "Rfc": "content_type"
          },
          {
            "start": 215,
            "end": 247
          }
        ]
      ],
      "is_encoding_problem": false,
      "body": {
        "Text": "hello\n"
      },
      "offset_header": 202,
      "offset_body": 248,
      "offset_end": 255
    },
    {
      "headers_rfc": {
        "content_type": {
          "ContentType": {
            "c_type": "message",
            "c_subtype": "rfc822",
            "attributes": null
          }
        }
      },
      "headers_raw": [
        [
          {
            "Rfc": "content_type"
          },
          {
            "start": 278,
            "end": 294
          }
        ]
      ],
      "is_encoding_problem": false,
      "body": {
        "Message": {
          "html_body": [
            1,
            5
          ],
          "text_body": [
            4,
            5,
            6
          ],
          "attachments": [],
          "parts": [
            {
              "headers_rfc": {
                "from": {
                  "Address": {
                    "name": null,
                    "address": "sub@domain.org"
                  }
                },
                "subject": {
                  "Text": "submsg"
                },
                "content_type": {
                  "ContentType": {
                    "c_type": "multipart",
                    "c_subtype": "alternative",
                    "attributes": {
                      "boundary": "sub1"
                    }
                  }
                },
                "date": {
                  "DateTime": {
                    "year": 2012,
                    "month": 8,
                    "day": 12,
                    "hour": 12,
                    "minute": 34,
                    "second": 56,
                    "tz_before_gmt": false,
                    "tz_hour": 3,
                    "tz_minute": 0
                  }
                }
              },
              "is_encoding_problem": false,
              "body": {
                "Multipart": [
                  1,
                  2
                ]
              },
              "offset_header": 295,
              "offset_body": 424,
              "offset_end": 710
            },
            {
              "headers_rfc": {
                "content_type": {
                  "ContentType": {
                    "c_type": "text",
                    "c_subtype": "html",
                    "attributes": null
                  }
                }
              },
              "is_encoding_problem": false,
              "body": {
                "Html": "<p>Hello world</p>\n"
              },
              "offset_header": 449,
              "offset_body": 474,
              "offset_end": 494
            },
            {
              "headers_rfc": {
                "content_type": {
                  "ContentType": {
                    "c_type": "multipart",
                    "c_subtype": "alternative",
                    "attributes": {
                      "boundary": "sub2"
                    }
                  }
                }
              },
              "is_encoding_problem": false,
              "body": {
                "Multipart": [
                  3,
                  6
                ]
              },
              "offset_header": 501,
              "offset_body": 555,
              "offset_end": 701
            },
            {
              "headers_rfc": {
                "content_type": {
                  "ContentType": {
                    "c_type": "multipart",
                    "c_subtype": "alternative",
                    "attributes": {
                      "boundary": "sub3"
                    }
                  }
                }
              },
              "is_encoding_problem": false,
              "body": {
                "Multipart": [
                  4,
                  5
                ]
              },
              "offset_header": 562,
              "offset_body": 616,
              "offset_end": 662
            },
            {
              "headers_rfc": {
                "content_type": {
                  "ContentType": {
                    "c_type": "text",
                    "c_subtype": "plain",
                    "attributes": null
                  }
                }
              },
              "is_encoding_problem": false,
              "body": {
                "Text": "sub3 text"
              },
              "offset_header": 623,
              "offset_body": 624,
              "offset_end": 634
            },
            {
              "headers_rfc": {
                "content_type": {
                  "ContentType": {
                    "c_type": "text",
                    "c_subtype": "plain",
                    "attributes": null
                  }
                }
              },
              "is_encoding_problem": false,
              "body": {
                "Text": "sub3 text2"
              },
              "offset_header": 641,
              "offset_body": 642,
              "offset_end": 653
            },
            {
              "headers_rfc": {
                "content_type": {
                  "ContentType": {
                    "c_type": "text",
                    "c_subtype": "plain",
                    "attributes": null
                  }
                }
              },
              "is_encoding_problem": false,
              "body": {
                "Text": "sub2 text2"
              },
              "offset_header": 680,
              "offset_body": 681,
              "offset_end": 692
            }
          ]
        }
      },
      "offset_header": 265,
      "offset_body": 295,
      "offset_end": 729
    },
    {
      "headers_rfc": {
        "content_type": {
          "ContentType": {
            "c_type": "text",
            "c_subtype": "plain",
            "attributes": null
          }
        }
      },
      "headers_raw": [
        [
          {
            "Rfc": "content_type"
          },
          {
            "start": 752,
            "end": 764
          }
        ]
      ],
      "is_encoding_problem": false,
      "body": {
        "Text": "Another part"
      },
      "offset_header": 739,
      "offset_body": 765,
      "offset_end": 778
    }
  ]
}