[CentOS] parsing an e-mail with perl

Thu Jan 13 02:36:20 UTC 2011
Nicolas Ross <rossnick-lists at cybercat.ca>

> I need to be able to pull off attachments from e-mails on the fly and
> then demime them and print them.  I have been studying MIME::Tools but
> was hoping someone could point me to a script example of something I
> could use.

Here's a little sniplet from a perl script I have to filter some attachement 
from mail :

use MIME::Tools;
use MIME::Parser;
use MIME::Decoder::QuotedPrint;
use MIME::Decoder::Base64;
use MIME::Decoder::Binary;
use MIME::Decoder::Gzip64;
use MIME::Decoder::NBit;
use MIME::Decoder::UU;
use MIME::Words qw(:all);

my $parser = new MIME::Parser;

my @message = <STDIN>;
my $entity = $parser->parse_data(\@message);

foreach my $part ($_[0]->parts)
 print $part->mime_type();

Thaere are other functins to the part object, my script simply pushes the 
part into a new array depending of the mime_type..