Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

splitting email messages from /var/spoolio...

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

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

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.
  • Comment on splitting email messages from /var/spoolio...

Replies are listed 'Best First'.
Re: splitting email messages from /var/spoolio...
by gellyfish (Monsignor) on Jul 20, 2006 at 15: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 15: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
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.