in reply to Parsing a multipart mail

I would suggest using Email::MIME - you can do something like:

use strict; use warnings; + use Email::MIME; use Email::Folder::Mbox; + my @received; my $box = Email::Folder::Mbox->new('/home/jonathan/mail/spam'); while ( my $mail = $box->next_message ) { my $main = Email::Simple->new($mail); + if ($main->header('Content-Type') and $main->header('Content-Type') + =~ /multipart/i ) { my $mess = Email::MIME->new($mail); + foreach my $part ($mess->parts()) { if ($part->content_type() =~ m%message/rfc822%i ) { print $part->as_string(); } } } + }

/J\

Replies are listed 'Best First'.
Re^2: Parsing a multipart mail
by stingray (Initiate) on Mar 02, 2005 at 05:20 UTC
    With MIME::Parser, you can get the full rfc/822 message by using the $part->body_as_string method and feeding that back into a new/reused MIME::Parser object.