Differences between revisions 1 and 2
Revision 1 as of 2005-03-22 05:46:47
Size: 1425
Editor: anonymous
Comment: missing edit-log entry for this revision
Revision 2 as of 2009-09-20 23:16:36
Size: 1425
Editor: localhost
Comment: converted to 1.6 markup
No differences found!

#created by Kurt Yoder; see 
#http://wiki.spamassassin.org/w/KurtYoder
#for updates on this script see 
#http://wiki.spamassassin.org/w/report_5fspam_2epl
#
#If you have "maildir" mailboxes, running spamassassin -r multiple
#times can be tedious for large numbers of spam. So you can use this
#script to run it for you.  Run it like this: "report_spam.pl
#your_spam_directory". Each message in your_spam_directory will then
#be learned in bayes *and* reported to the checksum services.

use strict;
use diagnostics;

my $spamassassin = '/usr/local/bin/spamassassin';
if( ! -x $spamassassin ){
   die( "Spamassassin not found; I looked in $spamassassin\n" );
}

if(
   ( defined( $ARGV[0] ) ) &&
   ( -d $ARGV[0] ) &&
   ( -r $ARGV[0] ) &&
   ( -x $ARGV[0] )
){
   my $path = $ARGV[0];
   #ensure received path has trailing slash
   $path =~ s|/?$|/|;
   print( "reporting messages in $path as spam\n" );
   my @files = `ls -A $path`;
   chomp( @files );
   foreach my $file( @files ){
      if( -r $path . $file ){
         #shell-escape all '=' and ':'
         $file =~ s/([=:])/\\$1/g;
         print( "reporting $file\n" );
         system( "$spamassassin -r < $path$file" );
      } else {
         print( "Ignoring un-readable file $file\n" );
      }
   }
} else {
   die( "Please specify a directory containing spam messages to report\n" );
}

report_spam.pl (last edited 2009-09-20 23:16:36 by localhost)