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

splitting email messages from /var/spoolio...

by abachus (Monk)
on Jul 20, 2006 at 18:54 UTC ( [id://562677]=perlquestion: print w/replies, xml ) Need Help??

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

hello again,

I'm trying to find an efficient way to count and/or split email messages from /var/spool/mail/<user>. Apart from opening the spool and iterating through it, could anybody suggest a module they know of that can do this well. I've had a quick look on cpan but got a bit lost.

thanks, Isaac.

Replies are listed 'Best First'.
Re: splitting email messages from /var/spoolio...
by gellyfish (Monsignor) on Jul 20, 2006 at 19:20 UTC

    Email::Folder and its relatives is probably what you want. You can see more about this at The Perl Email Project (though catch that quickly as the wiki seems to be favoured by comment spammers.)

    /J\

      hey, thanks i've started to read the site as of now.
Re: splitting email messages from /var/spoolio...
by madbombX (Hermit) on Jul 20, 2006 at 19:22 UTC
    I would have to say that your best bet (assuming I understand you correctly) is Mail::Box or Mail::Box::Manager. It's located here.

    Assuming that you are using mbox format for your mailboxes:

    use Mail::Box::Manager; my $mgr = Mail::Box::Manager->new; my $folder = $mgr->open(folder => $ARGV[0]) or die("Mailbox open error: $!"); print $folder->name. ": ".$folder->messages ." Total Messages\n"; # Iterate over the messages foreach (@$folder) { print "Message $_"; } $mgr->close() or die("Mailbox close error: $!");

    Untested.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-03-29 06:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found