1 # Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors
2 # License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
7 use constant MAX_SIZE => 1024 * 500; # same as spamc default
9 # drop plus addressing for matching
12 $str_addr =~ s/\+.*\@/\@/;
16 # do not allow Bcc, only Cc and To if ORIGINAL_RECIPIENT (postfix) env is set
18 my ($klass, $filter) = @_;
19 my $simple = $filter->simple;
20 return 0 unless $simple->header("Message-ID");
21 return 0 unless defined($filter->from);
22 return 0 if length($simple->as_string) > MAX_SIZE;
23 recipient_specified($filter);
26 sub recipient_specified {
28 my $or = $ENV{ORIGINAL_RECIPIENT};
29 defined($or) or return 1; # for imports
30 my @or = Email::Address->parse($or);
31 my $oaddr = __drop_plus($or[0]->address);
32 $oaddr = qr/\b\Q$oaddr\E\b/i;
33 my @to = Email::Address->parse($filter->to);
34 my @cc = Email::Address->parse($filter->cc);
35 foreach my $addr (@to, @cc) {
36 if (__drop_plus($addr->address) =~ $oaddr) {