Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Creating mail::message from retrieved text

by raflach (Pilgrim)
on Feb 08, 2005 at 18:56 UTC ( [id://429185]=perlquestion: print w/replies, xml ) Need Help??

raflach has asked for the wisdom of the Perl Monks concerning the following question:

So I'm downloading the mail from a pop3 box using:
use Net::POP3; my $pop = Net::POP3->new('www.myhost.com', Timeout => 90); if ($pop->login('listaddress+myhost.com','pass') > 0) { my $msgnums = $pop->list; foreach my $msgnum (keys %$msgnums) { my $msg = $pop->get($msgnum); } } $pop->quit;
Pretty much straight from the POP3 docs. Now I want to use Mail::Box::MH to save the retrieved messages to an MH style folder. So I add:
use Mail::Box::MH; my $folder = new Mail::Box::MH folder => '/mypath/myspecialmailboxfold +er';
at the top, and then in the loop I put:
my $MHmsg = join "",@$msg; $folder->addMessage($MHmsg);
which fails because addMessage must recieve a message object. So I search diligently for a (prefab) way to construct a message object from the plaintext that is returned from the POP3 get call because I know that I'm not competent enough to handle parsing all the possible (standard and non-standard) MIME and non-MIME headers and bodies for myself. I have had no luck. Can anyone point me in the right direction?

Replies are listed 'Best First'.
Re: Creating mail::message from retrieved text
by monsieur_champs (Curate) on Apr 29, 2005 at 15:43 UTC
Re: Creating mail::message from retrieved text
by redlemon (Hermit) on Feb 08, 2005 at 19:50 UTC

    You may want to experiment with Mail::Message->buildFromBody() which is part of the Mail::Box distribution

      Thanks, but buildFromBody, requires a Mail::Message::Body object, which requires the same type of parsing as Mail::Message. I just know there have to be hooks in there somewhere to read in a plaintext file and produce a Message object, but I haven't been able to find them. As an alternative does anyone have any e-mail header/body parsing routines that return some easily manipulable hash/array/whatever that I could then use to construct a message using build?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://429185]
Approved by Tanktalus
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (7)
As of 2024-03-28 21:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found