
Warren Bell
Deleted
Feb 6, 2000, 1:40 PM
Views: 5985
|
Re: How to check POP mail account with Perl?
|
|
|
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: ------------------ #!/usr/bin/perl use POP3Client; @hosts = ( "first.mail.host", "second.mail.host", ); $user = 'username'; $pass = 'xxxxxx'; foreach $host (@hosts) { $pop = new Mail::POP3Client( USER => "$user", PASSWORD => "$pass", HOST => "$host", ); print "\nChecking for mail at $host...\n\n"; $cnt = 0; for ($i = 1; $i <= $pop->Count(); $i++) { $cnt++; foreach ($pop->Head($i)) { /^(From):\s+/i and print $_, "\n"; #------if statement to detect username in To field of header------# if ((To) !~ /* $user/) { /^(From):\s+ - possible spammer\nDeleting message in 3 seconds../i and print $_, "\n"; sleep 3; $pop->Delete; #------end if statement------# } } } if ($cnt != 0){ print "\n"; } print "Found $cnt message\(s\) at $host\n"; } ---------------
|