Sometimes, Email::Simple and friends are too simple. I strongly suggest you look at Mail::Box. It looks big and complicated because of the incredibly complex class heirarchy, but read the Mail::Box::Cookbook and experiment with it and you'll find it's not terribly hard to use. Once you get used to it (and there is a big learning curve) it's a swiss-army-chainsaw for mail processing.
Given your question, you probably want something like this (not tested):
my $manager = Mail::Box::Manager->new; my $folder = $manager->open( folder => $ENV{MAIL} ); foreach my $message ( $folder->messages ) { next if $message->label( 'seen' ); my $bounce = $message->bounce( To => 'you@somewhere.com' ); $bounce->send; $message->label( 'seen' => 1 ); } $folder->close;
Look at Mail::Message for other things you can do with a message (reply, forward, etc.) There's also very good online documentation with links for a mailing list that is very responsive to questions.
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
In reply to Re: finding unread emails in IMAP maildir
by xdg
in thread finding unread emails in IMAP maildir
by chrisj0
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |