Here's a new plugin I just wrote called "check_spamlist" that seems to
work quite well for me (as always, YMMV):

# this plugin checks the abuse.easynet.nl spamlist-extended file
# Written 9 Nov 2003 by Andrew Pam <[EMAIL PROTECTED]>

sub register {
  my ($self, $qp) = @_;
  eval { require CDB_File };
  if ($@) {
    $self->log(0, "No spamlist.cdb support, could not load CDB_File module: $@");
  }

  $self->register_hook("mail", "mail_handler");
  $self->register_hook("rcpt", "rcpt_handler");
}

sub mail_handler {
  my ($self, $transaction, $sender) = @_;

  my %h;
  unless (tie(%h, 'CDB_File', "spamlist.cdb")) {
    $self->log(0, "tie of spamlist.cdb failed: $!");
    return DECLINED;
  }

  return (DECLINED) unless ($sender->format ne "<>"
                            and $sender->host && $sender->user);

  my $host = lc $sender->host;
  my $from = $sender->user . '@' . $host;

  $transaction->notes('spamlist', "Mail from spam address $from not accepted here")
    if defined $h{$from}
    || defined $h{$sender->user . '@'}
    || defined $h{$host}
    || defined $h{substr($host, index($host, '.'))};
  return (DECLINED);
}

sub rcpt_handler {
  my ($self, $transaction, $rcpt) = @_;
  my $note = $transaction->notes('spamlist');
  return (DENY, $note) if $note;
  return (DECLINED);
}


I run this plugin immediately after "check_spamhelo" but before
"check_badmailfrom" and "require_resolvable_fromhost" as it uses
less resources than the latter.  It relies on having an up-to-date
spamlist.cdb which is generated by this script run as a cron job
once an hour (please do NOT run more frequently, and do not run
exactly on the hour, to avoid overloading the server):

#!/bin/sh
cd /var/qmail/qpsmtpd
rsync -avzq rsync://informatie.easynet.nl:6666/spamblock/spamlist-extended.txt \
      spamlist-extended.txt
cdbmake-12 spamlist.cdb spamlist.tmp < spamlist-extended.txt


Share and enjoy,
                *** Xanni ***
-- 
mailto:[EMAIL PROTECTED]                         Andrew Pam
http://www.xanadu.com.au/                       Chief Scientist, Xanadu
http://www.glasswings.com.au/                   Technology Manager, Glass Wings
http://www.sericyb.com.au/                      Manager, Serious Cybernetics

Reply via email to