webadept has asked for the wisdom of the Perl Monks concerning the following question:

Hey Monks, I'm writing a little utility to clean up a POP3 account from spam before I get my mail. So far the code looks something like this..
$spamx = $spamdir.$spamfile; $pop = new Mail::POP3Client( USER => $account, PASSWORD => $passwd, HOST => $server) || die $pop->Message(); #$pop->Connect() >= 0 || die $pop->Message(); for( $i = 1; $i <= $pop->Count(); $i++ ) { foreach( $pop->Head( $i ) ) { if(/^(X-Spam-Score):\s+/i) { $_ =~ s/[a-z \(\-\):,_\*\s]//ig; chomp; if($_ > $threshold) { open(OUT, ">>$spamx") || open(OUT,">$spamx") || die + "could not open Spam file "; $pop->Retrieve($i); if(print OUT $pop->Body($i), "\n\n") { $pop->Delete($i); } else { print "Spam filter file can't be written too, Stoppin +g Program \n\n"; exit; } close(OUT); print $_ , "\n"; } } } # end foreach loop # } # end for every message in spool # $pop->Close();


Everything is working okay, no real problems, except the Delete. When I run the program twice against the same account the first run marks all of them as deleted, and the second run shows no mail found, but when I check the server que, or open a mail client (Eudora) against the same account, I get all the emails that should have been deleted. ??? and were seen as deleted by the above code. ??

I'm probably overlooking something stupid, and should just stop, drink lots of woopass and howl at the moon for a while, but thought I would see if one of you have had experinence with this problem, and hopfully could explain it to my tired mind.

Checked the back area, before I asked, didn't find anything, but if I missed it, sorry.

webadept

"Yeah, but you are taking the whole universe out of context"

Replies are listed 'Best First'.
Re: Mail::POP3Client Delete
by webadept (Pilgrim) on Sep 08, 2002 at 03:41 UTC
    Oh.. Checked the file permissions on the que, its a Linux box with Sendmail, lets see, I think that's about it.

    Thanks

    webadept

    Every day someone is doing what someone else said is impossible.
      To delete the message I do this: $msg = $pop->Uidl($m); my @id = split(/\s+/, $msg); $msg = "@id[0]"; $pop->Delete($msg);