Last active
October 23, 2023 08:43
-
-
Save gslin/a260b284f18c70c013ef412105049ac3 to your computer and use it in GitHub Desktop.
Cleanfeed + SpamAssassin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vim: set syntax=perl | |
use Mail::SpamAssassin; | |
my $sa_agent = Mail::SpamAssassin->new(); | |
sub local_filter_last { | |
return unless $hdr{Path} =~ /google-groups\.googlegroups\.com/; | |
my %myhdr = %hdr; | |
delete $myhdr{__BODY__}; | |
delete $myhdr{__LINES__}; | |
my $header_str = join "\n", map { "$_: $hdr{$_}" } keys %myhdr; | |
my $article_str = "$header_str\n\n$hdr{__BODY__}"; | |
my $mail = $sa_agent->parse($article_str); | |
my $status = $sa_agent->check($mail); | |
my $spamness = $status->is_spam(); | |
# GC first, to prevent from leaking. | |
$status->finish(); | |
$mail->finish(); | |
if ($spamness) { | |
my $reason = sprintf 'Reject Google Groups posting to %s by SpamAssassin', $hdr{Newsgroups}; | |
return reject($reason); | |
} | |
return; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment