#!/usr/bin/perl use strict; use warnings; use Mail::POP3Client; use MIME::Parser; my $pop = new Mail::POP3Client( USER => 'login', PASSWORD => 'password', HOST => 'server', USESSL => 1 ); my $fh = new IO::Handle(); my $parser = new MIME::Parser; for (my $i = 1; $i <= $pop->Count(); $i++) { open (OUT, ">msg-$i.msg"); $fh->fdopen( fileno(OUT), "w" ); $pop->HeadAndBodyToFile( $fh, $i ); close OUT; my $entity = $parser->parse_open("msg-$i.msg"); } $pop->close();