in reply to parsing and printing e-mail

MIME::Email - something like
use strict; use warnings; use Email::MIME; use Mail::POP3Client; my $pop = new Mail::POP3Client( USER => "my\@email.address", PASSWORD => "passwordxxxxx", HOST => "mail.mydomain.com" ); for( my $i = 1; $i <= $pop->Count(); $i++) { my $body = $pop->Body($i); my $parsed = Email::MIME->new($body); my $decoded = $parsed->body; print "<p>$decoded<p><hr>"; }

Replies are listed 'Best First'.
Re^2: parsing and printing e-mail
by keiusui (Monk) on Dec 17, 2009 at 19:55 UTC
    I already tried this. Decoding the body using Email::MIME still leaves the ugly headers intact. However, thanks for your response.

      Could you post an example of the "ugly headers"? That may provide a clue. I suspect a Content-Type problem.

        Sure, here is what an e-mail looks like if it contains both text/plain and text/html portions:

        This is a multi-part message in MIME format. ------=_NextPart_000_0009_01CA7F30.7F3A37C0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit From: sender@email.address Sent: Wednesday, December 16, 2009 9:28 PM To: test@email.address Subject: This is the subject This is the body. ------=_NextPart_000_0009_01CA7F30.7F3A37C0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable <html> <head> <body> This is the body. </body> </html> ------=_NextPart_000_0009_01CA7F30.7F3A37C0--

        I am trying to find the best way to retrieve just the HTML portion (intact, with the html tags still there). As you can see, there are all sorts of headers. Anyone know a good module for this?