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


in reply to Re^3: Geting attached files of emails (POP3)
in thread Geting attached files of emails (POP3)

NEW CODE: #!/usr/bin/perl

my $homedir='/home/celflog/www/teste';

use strict;

use Mail::POP3Client;

use IO::File;
use Mail::Message::Attachment::Stripper;


my $pop = new Mail::POP3Client(
USER => 'myuser',
PASSWORD => "mypass",
HOST => "mail.server.com"
);

my $msg=$pop->Retrieve(1), or die "$_\n";


print "$msg";


my $m = Mail::Message::Attachment::Stripper->new($msg);
my @attachments = $m->attachments;


foreach my $a(@attachments) {

next if $a->{content_type} !~ /jpeg|jpg/i;

# Ignore invalids attached files
my $f = new IO::File "$homedir" . $a->{filename}, "w" or die "Can not create file!";

print $f $a->{payload};

}

He continue showing: Need a message at teste.cgi line 25