my $i = substr $subject, 0, 30; my $l = $i.(" " x (30 - length $i)).": "; # Get rid of those bound to be dropped # based on env-to if (defined $acc && grep { $_ eq $acc } @accDrop) { info("${l}Sent to account \"$acc\", drop"); drop; return 1; } # based on subject { if (my @a = grep {$subject =~ /\Q$_\E/i} @subjectDrop) { info("${l}Subject contains \"$a[0]\", drop"); drop; return 1; } } # based on from host (searches end of host) { if (my @a = grep {$fromHost =~ /\Q$_\E$/i} @fromHostDrop) { info("${l}From host ends with \"$a[0]\", drop"); drop; return 1; } } # based on from address if (grep {$fromAddr =~ /^\Q$_\E$/i} @fromAddrDrop) { info("${l}From address is \"$fromAddr\", drop"); drop; return 1; } # based on from name if (grep {$fromName =~ /^\Q$_\E$/i} @fromNameDrop) { info("${l}From name is \"$fromName\", drop"); drop; return 1; } # -- work out where to move to # move based on from host foreach my $into (keys %fromHostMove) { { if (my @a = grep {$fromHost =~ /\Q$_\E$/i} @{$fromHostMove{$into}}) { info("${l}From host ends \"$a[0]\", possibly moving into $into"); move($into); last; } } } # move based on from address foreach my $into (keys %fromAddrMove) { if (grep {/^\Q$fromAddr\E$/i} @{$fromAddrMove{$into}}) { info("${l}From address \"$fromAddr\", possibly moving into $into"); move($into); last; } } # move based on subject foreach my $into (keys %subjectMove) { { if (my @a = grep {$subject =~ /\Q$_\E/i;} @{$subjectMove{$into}}) { next if ($into eq "spam"); info("${l}Subject contains \"$a[0]\", possibly moving into $into") ; move($into); $notspam = 1; last; } } } # move based on from name foreach my $into (keys %fromNameMove) { if (grep {/^\Q$fromName\E$/i} @{$fromNameMove{$into}}) { next if ($into eq "spam"); info("${l}From name is \"$fromName\", possibly moving into $into"); move($into); $notspam = 1; last; } } # move based on account if (defined $acc) { foreach my $into (keys %accMove) { if (grep {$_ eq $acc} @{$accMove{$into}}) { info("${l}Sent to account \"$acc\", possibly moving into $into"); move($into); last; } } } # spam check my $foundspam = 0; if (exists $subjectMove{spam} && !$notspam) { { if (my @a = grep {$subject =~ /\Q$_\E/} @{$subjectMove{spam}}) { info("${l}Subject contains $a[0], this could be spam"); $foundspam = 1; } } } # if not a bulk folder unless (grep {$folder eq $_} @folderBulk) { # suspected spam if ($foundspam) { info("${l}Suspected spam and headed to bulk, possibly moving into spam"); move('spam'); return 1; } # not moving if ($folder eq $folderCurrent) { info("${l}Not moving"); return 1; } # free to move if spam if ($folder eq 'spam') { info("${l}Moving into spam"); return 1; } # don't move if unseen unless ($mes->{flag}{seen}) { info("${l}Unseen message, not moving"); move($folderCurrent); return 1; } # free to move if quickmove folder if (grep {$folder eq $_} @folderQuickmove) { info("${l}Quickmove destination, moving now"); return 1; } # don't move if recent if ($ageDay < $ageBeforeMove) { info("${l}Recent message, not moving"); move($folderCurrent); return 1; } info("${l}Carrying out action"); return 1; } # OK, so a bulk folder, kill if spam if ($foundspam) { info("${l}Probably spam sent to bulk folder, drop"); drop; return 1; } 1;