[CentOS] parsing an e-mail with perl

Sun Jan 16 03:28:44 UTC 2011
Gregory P. Ennis <PoMec at PoMec.Net>

On Wed, 2011-01-12 at 21:36 -0500, Nicolas Ross wrote:
> > 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.. 
> 

Nicolas,

Thanks for your help.  I tried using it in the form of 

cat mailfile.txt | /usr/local/bin/s.mime.002.pr

and received the below error message.

Can't locate object method "tmp_recycling" via package "MIME::Parser"
at /usr/local/bin/s.mime.002.prl line 17.

I have perl-MIME-tools-5.420-2.el5.rf.noarch installed.

Any ideas?

Greg