in reply to Mail::Pop3Client - want to get consistent body text

You're probably looking for some MIME parsing module, like MIME::tools or Email::MIME.

  • Comment on Re: Mail::Pop3Client - want to get consistent body text

Replies are listed 'Best First'.
Re^2: Mail::Pop3Client - want to get consistent body text
by ksublondie (Friar) on May 19, 2009 at 21:29 UTC
    Email::MIME only returns the text for plain text emails, but body() on HTML emails returns nothing. Still need a way to get the HTML emails from Cox.

    Still playing with MIME::Tools...

      If you show us your code, it would really help us to help you. Note that you should pass to Email::MIME the whole message including headers (at least MIME headers) in order it could parse it. Also HTML messages are usually multipart, so you have to invoke parts() before body()

        Here's what I have now for my code:
        for (my $i=1; $i<=$messages; $i++){ foreach($pop->Head($i)){ if($_=~/^From:[^<>]*\<(.*)\>/){ $emails[$i]->{'from'}=$1; } if($_=~/^Subject:(.*)/){ $emails[$i]->{'subject'}=$1; } } my $headAndBody=$pop->HeadAndBody($i); my $email=Email::MIME->new($headAndBody); my @parts=$email->parts(); my $body=$email->body(); print $body."\n\n"; $emails[$i]->{'body'}=$body; }