[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;
$parser->output_to_core(0);
$parser->extract_nested_messages(0);
$parser->tmp_to_core(1);
$parser->tmp_recycling(1);
$parser->use_inner_files(0);
$parser->filer->ignore_filename(1);

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..