--Apple-Mail-16--694122637 Content-Transfer-Encoding: base64 Content-Type: application/pdf; x-unix-mode=0644; name="bus-schedule.pdf" Content-Disposition: inline; filename=some-file.pdf (then base64 code here) --Apple-Mail-18--693549197 Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-mac-type=2A2A2A2A; x-unix-mode=0644; x-mac-creator=48647261; name="somefilename" Content-Disposition: attachment; filename=somefilename (then the file is here) #### #!/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();