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!
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 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
On 13 January 2011 01:27, Gregory P. Ennis PoMec@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...