#!/usr/bin/perl -w use strict; use Mail::POP3Client; use MIME::Parser; my $pop = new Mail::POP3Client( USER => "email\@mydomain.com", PASSWORD => "mypassword", HOST => "mail.mydomain.com" ); my $i; for( $i = 111; $i <= $pop->Count(); $i++ ) { foreach( $pop->Head( $i ) ) { /^(From|Subject):\s+/i && print $_, "\n"; my $dir = '/some/folder/somewhere/attachments'; my $parser = new MIME::Parser; my $io = new IO::File; if ($io->open( "> $dir/raw-message.$i")) { $pop->HeadAndBodyToFile( $io, $i ); $io->close; print "Parsing $dir/raw-message.$i...\n"; $parser->parse( IO::File->new( "$dir/raw-message.$i") ); } } } $pop->Close();