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 recipient is set
18 my ($klass, $filter, $recipient) = @_;
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, $recipient);
26 sub recipient_specified {
27 my ($filter, $recipient) = @_;
28 defined($recipient) or return 1; # for mass imports
29 my @recip = Email::Address->parse($recipient);
30 my $oaddr = __drop_plus($recip[0]->address);
31 $oaddr = qr/\b\Q$oaddr\E\b/i;
32 my @to = Email::Address->parse($filter->to);
33 my @cc = Email::Address->parse($filter->cc);
34 foreach my $addr (@to, @cc) {
35 if (__drop_plus($addr->address) =~ $oaddr) {