Re: [Exim] spamassasin woes [ fixed almost ]

Página Inicial
Delete this message
Reply to this message
Autor: Ben Lutgens
Data:  
Para: exim-users
Assunto: Re: [Exim] spamassasin woes [ fixed almost ]
--
On Wed, 2002-01-09 at 14:30, dman wrote:

> | --
> | [ Content of type text/x-perl deleted ]
> | --
> | [ Content of type application/pgp-signature deleted ]
> | --
>
> to happen. Change your mailer settings to send plain-text only, no
> HTML, and your messages should arrive unbutchered.


I'm not sending html, plain text only. Perhaps evolution is doing
something nasty with the mime type setting. I'll just include it in the
text of the mail as opposed to an attachment.

BTW, the attachments work on the lists I administer (mailman)

#-------------------- SNIP
#!/usr/bin/perl
# This is an small wrapper script around Mail::SpamAssassin for the use
# with the exim MTA
# It is released under the Terms of GNU General Public License (GPL) so
# use at your own risk!
# author Ben Lutgens <blutgens@???>
# Heavily based on the spamcheck.pl available
# http://bogmog.sourceforge.net/file_show.php3?file_id=34 and then
adapted
# to use Spamassassins prefs file. I also added the reporting bit. I'm a
# terrible perl programmer so don't bother flaming me for poor coding
# habits :-) I will take suggestions for improvments though as I'm just
# learning perl.
#
# Make sure you check the variables $exim, $params, and $do_report
#
# Usage:
#
# To run this script from the command line for testing
# you'll need an unmolested email. Grab the MS°ID out of it and then run
it
# like so
# ./spamcheck.pl $MSGID $TO_ADDRESS < $SPAMFILE

use Mail::Audit;
use Mail::SpamAssassin;
use Mail::SpamAssassin::PerMsgStatus;
use Data::Dumper;
$exim     = '/usr/sbin/exim';       #Full path to exim
$params   = '-oMr spam-scanned -i'; #Additional params no need to change
$do_report = '1';                   # set to 1 to report mail to online
db's



#These are given as command line arguments by exim:
$sender = shift(@ARGV);
$sender = '<>' if $sender eq '';
$recpt = '';
while (@ARGV){
$recpt = $recpt.' '.shift(@ARGV);
}

####### Main script
###########################################################

# Read Mail from STDIN
my $mail = Mail::SpamAssassin::MyMailAudit->new();

my $spamtest = Mail::SpamAssassin->new({
# Since I run exim as "daemon" i don't want it to try and make a
# ~daemon/.spamassassin.prefs
'dont_copy_prefs' => '1',
# For some reason this next one is needed to prevent an error stating
# "Error copying default prefs" even though the above means "don't
copy
# them"
'userprefs_filename' => '/etc/spamassassin.prefs'
});


my $status = $spamtest->check ($mail);


# This next part is ugly and experimental, I haven't verified that it
will
# actually report to razor yet since I haven't been able to snag a
# non-tagged, unmolested, mail that razor isn't aware of yet :-)
#
# First I check to see if $do_report is set to 1 and make sure the
# is_spam() is true
if (($do_report) && ($status->is_spam ())) {
   # For testing
   #   print "Is spam\n";
   #
   #   This is quite a kludge, I'm sure there's a more sane way of doing
   #   this but I'm a terrible perl programmer. Here we're checking to
see
   #   if razor already knows about this dreaded piece of spam, no
reason
   #   to report it if it is....
  if (Dumper($status) =~ (/Hit!.*Listed.in.Razor*/)) {
      $spamtest->report_as_spam($mail, {
         'dont_report_as_razor' => '1'
      });
      #  More debug crap, unwanted if using with an MTA but handy from
      #  command line.
      #  print "did not report to razor\n";
  } else {
     $spamtest->report_as_spam($mail);
     #   I love print
     #print "Didn't reported to razor";
  }
  #   I only use this for testing.
  #  } else {
  #   print "Is not SPAM!";
}




# This stuff has to be last. We don't want to report a modified mail
to
# the online databases. And calling pipe sends exit() or some such and
# ends the whole shebang.....
$status->rewrite_mail ();

#Add the X-Spam Headers:
$mail->pipe("$exim $params -f $sender $recpt");
#--------------------- SNIP

--
Ben Lutgens
Sistina Software Inc.
Kernel panic: I have no root and I want to scream
--
[ Content of type application/pgp-signature deleted ]
--