UserPreferences

PerlScript


Note: This wiki is now frozen; you can no longer edit it, and no interactive features work.

This uses [WWW]Mail::POP3Client to connect to the SpamBayes server and delete any mail that has a spam header. (On my system I have sb_server proxying to port 8110.)
#!/usr/bin/perl

use Mail::POP3Client;

$mail = new Mail::POP3Client (
        HOST => "127.0.0.1",
        PORT => 8110);
$mail-> User("your-pop3-username-here");
$mail-> Pass("your-pop3-password-here");
$mail-> Connect() || die $mail->Message();
print "--------------\n";
print $mail->Count(), " message(s) to be procesed\n";
my $deleted = 0;

for ($i = 1; $i <= $mail->Count(); $i++) {
        print "\t--------------\n";
        foreach ($mail->Head($i)) {
                /^(From|Subject):\s+/i && print "\t", $_, "\n";
                if (/^(X-Spambayes-Classification: spam)/i) {
                        print "\t* S P A M *\n";
                        $mail->Delete($i);
                        $deleted++;
                }
        }
}
$mail->Close();

print "--------------\n";
print "$deleted spam email(s) deleted\n";