use Mail::POP3Client; $pop = new Mail::POP3Client( USER => "*****", PASSWORD => "*****", HOST => "127.0.0.1" ); open(OUTPUT,">mail.xml") or die; $id=0; for( $i = 1; $i <= $pop->Count(); $i++ ) { $id++; print OUTPUT "\n"; $header=$pop->Head( $i ); $body=$pop->Body($i); $header =~ m#^From: (.*?)$#m; $from=$1; $header =~ m#^To: (.*?)$#m; $to=$1; $header =~ m#^Subject: (.*?)$#m; $subject=$1; $header =~ m#^Date: (.*?)$#m; $date=$1; #print "$header\n"; print OUTPUT "$from\n"; print OUTPUT "$to\n"; print OUTPUT "$subject\n"; print OUTPUT "$date\n"; print "Msg ID: $id\n"; #have to edit here if ($body=~/^--$/) { next; } else { print OUTPUT "\n$body\n<\body>\n"; } #ends print OUTPUT "\n"; } $pop->Close();