title: Parsing email with Email::MIME and multipart/mixed with subparts
body: <p>I'm a perl novice and have been working with Email::MIME to figure out how to parse emails with multiparts correctly. I've just identified another combination that my current efforts have not been able to properly read.</p>
  
  <pre><code>     Content-Type: multipart/mixed; boundary="===============1811908679642194059=="
   MIME-Version: 1.0
  
   This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
   --===============1811908679642194059==
   Content-Type: multipart/signed; micalg=pgp-sha256;
    protocol="application/pgp-signature";
    boundary="lGJM242FL2E9Wh4auTNwQRWOeFI0Wj9mB"
  
   This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
   --lGJM242FL2E9Wh4auTNwQRWOeFI0Wj9mB
   Content-Type: multipart/alternative;
    boundary="------------CC2F0C038668F58F6EDEA0D2"
  
   This is a multi-part message in MIME format.
   --------------CC2F0C038668F58F6EDEA0D2
   Content-Type: text/plain; charset=windows-1252
   Content-Transfer-Encoding: quoted-printable
  
   =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
   =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
   =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
  </code></pre>
  
  <p>The text/plain part is the part that I want, but reading the "text" component just gives me the "This is a multi-part..." line and that's it. This is the code I've developed to read other emails with similar subparts, but it doesn't properly interpret this one.</p>
  
  <p>It looks to be related to the "body" function as part of Email::MIME:</p>
  
  <pre><code> This decodes and returns the body of the object as a byte string. For
   top-level objects in multi-part messages, this is highly likely to be
   something like "This is a multi-part message in MIME format."
  </code></pre>
  
  <p>What is the proper function to use within Email::MIME to properly read this content type?</p>
  
  <p>How do properly identify the content-type in this email? Is it "multipart/mixed" or "text/plain" or "multipart/alternative"?</p>
  
  <p>Do I even want to use the subparts method here?</p>
  
  <pre><code> my @mailData;
   my $msg = Email::MIME-&gt;new($buf);
   foreach my $part ( $msg-&gt;subparts ) {
      foreach my $sub_part ($part-&gt;subparts) {
           print $sub_part-&gt;content_type;
          if ($sub_part-&gt;content_type =~ m!text!) {
              @mailData = split( '\n', $sub_part-&gt;body);
           }
      }
   }
  </code></pre>
  
  <p>The code above only prints "This is a multi-part message..." in the @mailData array.</p>