diff -Nur qpsmtpd-0.96.old/plugins/spamassassin qpsmtpd-0.96/plugins/spamassassin --- qpsmtpd-0.96.old/plugins/spamassassin 2018-03-11 00:31:05.427000000 -0500 +++ qpsmtpd-0.96/plugins/spamassassin 2018-03-11 00:40:36.117000000 -0500 @@ -121,6 +121,11 @@ If the X-Spam-User header is present, the LDA should submit the message to spamd for re-processing with the recipients address. +=head 1 Force SPAM Check even if is_immune +You can fill a file with a list of exception that will go under SPMA check even +if qpsmtpd flag the connection as immune. The file is forcespamcheck. Enter an ip +per line. As an example if you have fetchmail running on 127.0.0.200, simply add +this ip on a line in forcespamcheck file. =head1 CHANGES @@ -134,7 +139,10 @@ config. Subverting their changes there is unexpected. Making them read code to figure out why is an unnecessary hurdle. * added assemble_message, so we can calc content size which spamd wants - +2018.03.11 - Jean-Philippe Pialasse + * added an exception list forcespamcheck to is_immune. This is useful if you are + running a local deamon such as fetchmail, which connection should still go through + spamassassin testing, even if considered immune because connect as local. =cut use strict; @@ -170,7 +178,7 @@ sub data_post_handler { my ($self, $transaction) = @_; - return DECLINED if $self->is_immune(); + return DECLINED if $self->is_immune() and ! $self->is_in_forcespamcheck() ; my $limit = $self->{_args}->{size_limit} || 500_000; if ($transaction->data_size > $limit) { @@ -193,6 +201,26 @@ return $self->reject($transaction); } +sub is_in_forcespamcheck { + my $self = shift; + + my %forcespamcheck = map { $_ => 1 } $self->qp->config('forcespamcheck'); + + my $ip = $self->qp->connection->local_ip; + + while ($ip) { + if (exists $forcespamcheck{$ip}) { + $self->log(LOGINFO, "$ip in force spam check"); + return 1; + } + $ip =~ s/(\d|\w)+(:|\.)?$// or last; # strip off another octet + } + + $self->log(LOGDEBUG, "no match in forcespamcheck"); + return; +} + + sub select_spamd_username { my ($self, $transaction) = @_;