Patch to make SpamAssassin work with gotmail; updated for gotmail 0.7.9. Requires the Perl module Mail::SpamAssassin. --- gotmail.old 2003-03-13 18:31:38.000000000 -0700 +++ gotmail 2003-03-13 18:40:49.000000000 -0700 @@ -31,6 +31,8 @@ require 5.004; +# Uncomment this if you have SpamAssassin installed +# use Mail::SpamAssassin; use English; use URI::Escape; use POSIX qw(tmpnam); @@ -38,7 +40,7 @@ use strict; # Signal handlers: -$SIG{INT} = $SIG{__DIE__} = +$SIG{INT} = $SIG{TERM} = sub { my($text) = @_; print STDERR "gotmail died with message: $text\n"; @@ -88,6 +90,7 @@ my($conf_save_to_login) = 0; # 0 = no, 1 = yes my($conf_procmail) = 0; # 0 = no, 1 = yes my($conf_procmail_bin) = '/usr/bin/procmail'; +my($conf_sa) = 0; # 0 = no, 1 = yes # Global variables... my($host) = ""; # The name of the hotmail server we are talking to... @@ -169,6 +172,7 @@ print " --use-procmail Send all messages only to procmail\n"; print " --procmail-bin Use this program as procmail (default is\n" . " /usr/bin/procmail) (implies --use-procmail)\n"; + print " --use-sa Use SpamAssassin to not download spam\n"; print " --curl-bin Specify the path to the cURL program if it's\n" . " not in your path.\n"; print " --silent Do not print messages\n"; @@ -262,6 +266,8 @@ $conf_procmail = 1; } elsif ($_ =~ /^curl-bin=(.+)$/i) { $conf_curl = $1; + } elsif ($_ =~ /^use-sa/i) { + $conf_sa = 1; } } @@ -406,6 +412,9 @@ dispUsageAndExit(); } } + elsif ($element =~ /^--use-sa$/i) { + $conf_sa = 1; + } else { dispText("Unrecognized option $element\n"); dispUsageAndExit(); @@ -887,9 +896,26 @@ return; } + my $Message = getEmail($msg_url, 1, $foldername); + + # Check for spam, if requested to. Probable SPAMS are + # not downloaded + + if ($conf_sa) { + my $SpamTest = Mail::SpamAssassin -> new(); + + my $MessageObject = $SpamTest -> check_message_text($Message); + my $IsSpam = $MessageObject -> is_spam(); + + if ($IsSpam) { + dispText("Probably spam, skipping.\n"); + next; + } + } + # Are we resending or saving? if ($conf_procmail) { - my($output) = getEmail($msg_url, 1, $foldername); + my($output) = $Message; dispText("Sending mail message to procmail..."); open PR,"|" . $conf_procmail_bin; print PR $output; @@ -897,7 +923,7 @@ print "Done.\n"; } elsif ($resend_address eq "") { - my($output) = getEmail($msg_url, 1, $foldername); + my($output) = $Message; my($outfile) = $conf_folder_directory; if ($conf_save_to_login) { @@ -912,7 +938,7 @@ doSaveEmail($outfile, $output); dispText("Saving message to $outfile...\n"); } elsif ($conf_smtpserver) { - my($output) = getEmail($msg_url, 1, $foldername); + my($output) = $Message; doResendSMTPEmail($resend_address, $output, $conf_smtpserver); } else { my($output) = getEmail($msg_url, 0, $foldername);