The easiest way to check a pop account is to use the Mail::POP3Client module, which offers a lot of options, including getting the count of messages, getting the total size of the mailbox, deleting messages, etc.

Perfect! Ok I got this code below working as a command line script but I need to figure out the way to detect if the "To:" field of the header contains the $user variable. Do you know how I can do that? I looked at the documentaion for the module but can't find it anywhere. I'll highlight the part I'm talking about: