The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/usr/bin/perl
#############################################################################
## isspam
## Copyright (C) 2004  Martin Ward  http://www.cse.dmu.ac.uk/~mward/
## Email: martin@gkc.org.uk
##
## This program is free software; you can redistribute it and/or modify
## it under the same terms as Perl itself, either Perl version 5.8.1 or, at
## at your option, any later version of Perl 5 you may have available.
##
#############################################################################
# Learn a message as SPAM: train on errors only
#

use strict;
use warnings;
use Mail::SpamFilter ':all';

my $HOME = $ENV{'HOME'} || $ENV{'LOGDIR'} ||
                (getpwuid($<))[7] || die "You're homeless!\n";

my @filters = @Mail::SpamFilter::FILTER_LIST;
@filters = grep { $_ ne "dspam" } @filters;

my $V = 1;
if (@ARGV && $ARGV[0] eq "-s") {
  $V = 0;
  shift(@ARGV);
}

if (@ARGV && $ARGV[0] eq "x" && -f "$HOME/Documents/x") {
  $ARGV[0] = "$HOME/Documents/x";
}

# Slurp message from command line or STDIN:
undef $/;
my $msg = <>;
die unless defined($msg);

$msg =~ s/\nX-Spam-Votes:.*//;

my ($tags, $header, $body) = filter_message($msg, @filters);

my ($spam_count, $good_count, $spam_voters, $good_voters)
  = count_votes($tags, @filters);

# Don't report to wpbl:
#$good_voters = [grep { $_ ne "wpbl" } @{$good_voters}];

print "Reporting message to: @{$good_voters}\n" if $V;

close(STDOUT);
open(STDOUT, ">/dev/null");

report_message("spam", $msg, @{$good_voters});