I"m lost in a bunch of twisty passages all in the Email:: world :o). my problem is {I think} very simple but the Email modules seem much more focused on creating/modifying messages and I can't see how just to *examine* a message.

What I want to do a mock-email-reader. This means I need to parse out the headers {I just need things like from/to/subject/date} and then find the "body" of the message. There seem to be three types of incoming emails one is plain text, another in plain html {that is no multipart but just HTML.. I got one just today:

X-CMAE-Envelope: MS4xfLUIIc3gwFFCUTu1+RYnII5snX2pyaUrABakvIQ567LlL7RBF +Ly4Wo65N93eCIInGj50aDn6TLwhXwJbk7HKUHu2pUzH8OWeKTJoF2xE/w3tkTQrR8cj Kh4gBf/TMflzvBVgeRGN7++n/ZIwr/endxydKhxB1KRKrAoSBcA1O3+KsH4dy7QKym+yU +9SP+8B9fQ== X-PMFLAGS: 34095744 0 65537 PQVHWQ2O.CNM X-CC-Diagnostic: Body contains "click here" (20) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:/ +/www.= w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns:o=3D"urn:schemas-microsoft-com:office:office" xmlns:v=3D"u +rn:sc= hemas-microsoft-com:vml">=20 <head> <!--[if gte mso 9]><xml><o:OfficeDocumentSettings><o:AllowPNG/ +><o:P= ixelsPerInch>96</o:PixelsPerInch></o:OfficeDocumentSettings></xml><![e +ndif]= -->=20
and of course a multipart message {in which case I'd want the HTML part}.

This feels like it should be easy but so much of Email::* is occupied about modifying/adding/MIMEing, etc that I can't separate out the simple "parse and extract" machinery I need. Any advice/guidance/tutorial? THANKS


In reply to Parsing an email by BernieC

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.