Have you looked at Mail::Box ? It does all you want and more.
#!/usr/bin/perl use strict; use warnings; use Mail::Box::Manager; my $manager = Mail::Box::Manager->new(); # source folder my $source_folder = $manager->open( folder => '/path/to/folder' ) or die $!; # two destinations my $destination_1 = $manager->open( folder => '/path/to/destination/1', create => 1, access => 'rw', ) or die $!, my $destination_2 = $manager->open( folder => '/path/to/destination/2', create => 1, access => 'rw', ) or die $!; foreach my $msg ( $source_folder->messages() ){ if( $msg->isMultipart() ){ # msg has attachments } if( $msg->subject() =~ m/some_flag/ ){ # do something with msg # $msg->copyTo($destination_1); # or $manager->copyMessage($destination_2, $msg ); } } $manager->closeAllFolders(); 1;
It has great documentation as well!
In reply to Re: UNIX Mail Box and Mail Parsing
by crouchingpenguin
in thread UNIX Mail Box and Mail Parsing
by draconis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |