Dear List, 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. Any help would be appreciated - Thanks! -- Greg Ennis
> 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..
On 13 January 2011 01:27, Gregory P. Ennis <PoMec at pomec.net> wrote:> Dear List, > > 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.The modern way to handle email in Perl is to use the modules created by the "Perl Email Project". These are largely the modules on CPAN that start with Email::. In your case, I suspect you want Email::MIME. http://search.cpan.org/perldoc?Email::MIME Cheers, Dave... -- Dave Cross :: dave at dave.org.uk http://dave.org.uk/ @davorg