Hello folks

I just canīt find any module that filters email headers correctly. I am using Email::Filter now. Maybe Iīm doing something wrong, so here it is. Itīs a little dirty yet, so please donīt mind that:

use Net::POP3; use Email::Filter; my $pop = Net::POP3->new($host); if ($pop->login($user, $pass) > 0) { my $msgnums = $pop->list; # hashref of msgnum => size foreach my $msgnum (keys %$msgnums) { my $msg = $pop->getfh($msgnum); my $message; while (<$msg>) { $message .= $_; } my $mail = Email::Filter->new(data => $message); my $body = $mail->body; print $body; # $pop->delete($msgnum); } } $pop->quit;
Email::Filter says this is the body:
This is a multi-part message in MIME format. ------=_NextPart_000_0025_01C5BE3F.21ECA0A0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Hello Just to test! Bye! Andr=E9 ------=_NextPart_000_0025_01C5BE3F.21ECA0A0
Ok, I can strpe out the first block before the \n\n and the last one too. But is this is supposed to work will all mesages? Isnīt there a cleaner way? Also because I will need to treat attachments too, and now I donīt have a clue of how to do that. Maybe this dirty solution doesnīt work with emails carrying attachments.

Please give me a hand if you can

Thanks

Andre_br


In reply to Problems parsing emails from Net::Pop3 with Email::Filter by Andre_br

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.