Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Re: Re: Parsing a Unix Mbox

by Corion (Patriarch)
on Jul 16, 2002 at 19:55 UTC ( [id://182222]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Parsing a Unix Mbox
in thread Parsing a Unix Mbox

Yes, this task is very difficult to do right without a module, and I won't explain it here, as explaining it means reformulating the mbox manpage (found here for example) and Mail::Box handles it very nicely. I have only used Mail::Box after version 2, but I guess that the basic methods haven't changed that much since :

#!/usr/bin/perl -w # Some vestige of local delivery # For another method, have a look at Mail::LocalDelivery use strict; use Mail::Box; use Mail::Box::Manager; use Mail::Message; use Mail::Message::Construct; use vars qw($localmailbase $foldername); use vars qw($mgr $folder); $host = 'hera.informatik.uni-frankfurt.de'; $localmailbase = "/home/corion/mail/"; $foldername = "informatik"; $mgr = Mail::Box::Manager->new(folderdir => $localmailbase, default_folder_type => 'mbox', ); $folder = $mgr->open( folder => $foldername, access => 'rw', create => + 1 ); die "Couldn't open mailfolder '$foldername' : $!\n" unless $folder; print "Using folder ",$folder->name,"\n"; my %messageIDs; %messageIDs = map { $_->get("Message-ID"), $_ } ($folder->messages); my $msg; foreach $msg ($folder->messages) { print "*** The content of this message is :\n"; print $msg->body; } $mgr->close($folder);

I don't have access to any older Mail::Box documentation at the moment, but each message should have the body method, which returns the body of the message as a string.

perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2024-04-25 15:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found