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:
How i can get the attached files of a mail message?
My CODE:
He don't work ...#!/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}; }
20061227 Janitored by Corion: Added code tags as per Writeup Formatting Tips
Back to
Seekers of Perl Wisdom