http://www.perlmonks.org?node_id=591866

MiDgArD has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
How i can get the attached files of a mail message?

My CODE:


#!/usr/bin/perl $homedir='/home/celflog/www/teste'; use Mail::POP3Client; use IO::File; use Mail::Message::Attachment::Stripper; $pop = new Mail::POP3Client( USER => 'myuser', PASSWORD => "mypass", HOST => "mail.server.com" ); $msg=$pop->Retrieve(1); print "$msg"; $m = Mail::Message::Attachment::Stripper->new($msg); @attachments = $m->attachments; foreach $a(@attachments) { next if $a->{content_type} !~ /jpeg|jpg/i; # Ignore invalids attached files $f = new IO::File "$homedir" . $a->{filename}, "w" or die "Can not +create file!"; print $f $a->{payload}; }
He don't work ...

20061227 Janitored by Corion: Added code tags as per Writeup Formatting Tips