#!/usr/bin/perl -w ## import modules use lib '/Users/squiddy/sandbox/lib/'; use Mail::POP3Client; use MIME::Parser; ## create a new MIME parser object my $parser = new MIME::Parser; $parser->output_under("/Users/squiddy/sandbox/mailtemp/"); $parser->output_to_core(1); ###### code removed for simplicity ######### ## get mail $pop = new Mail::POP3Client( USER => "squiddy", PASSWORD => "notmypw", HOST => "pop3.squiddy.com", USESSL => true ); ###### code removed for simplicity ######### ## loop through each item on the POP3 server for ($i = 1; $i <= $pop->Count(); $i++) { ## get the unique email UIDL (out of a returned string "N XXXXXXX") $mailnum = $pop->Uidl($i); @maildat = split(" ",$mailnum); $mailnum = $maildat[1]; # print "$mailnum\n"; ## if it doesn't already exist in the database if (exists $hash{$mailnum}) { # print "nothing here\n"; } else { ###### code removed for simplicity ######### ## get email body $emailmessage = $pop->HeadAndBody($i); ###### code removed for simplicity ######### ## output the MIME parts $entity = $parser->parse($emailmessage) or die "parse failed\n"; } } ## close the connection $pop->close(); ###### code removed for simplicity #########