[Mimedefang] all_spam_to question
Kelson Vibber
kelson at speed.net
Thu Jan 29 18:17:10 EST 2004
At 12:36 PM 1/29/2004, Fred Felgenhauer wrote:
>Here is my workaround. I am doing stream_by recipient and score
>USER_IN_ALL_SPAM_TO set to 0 (or else
>other recipients of same e-mail get message tagged as not spam)
>
>How costly is reading the local.cf for each recipient?
Less than running SA in the first place, I expect, but there are faster
ways to do this.
What I do is create a hash table at filter initialization, then check
whether an entry exists for each recipient. It checks each recipient in
filter_begin, and if any values are found it calls
stream_by_recipient. That way, when it gets to filter_end and the values
are actually important, it knows there's only one recipient - plus it
doesn't split up and resend the message if it isn't necessary.
So something like this early on (outside of any subroutines):
%spam_fan = {
'ilikespam at here.com' => 1,
'ilikespamtoo at here.com' => 1
};
Then something like:
sub all_spam_to($) {
my $rec = lc($_[0});
$rec =~ tr/<>//d;
return exists($spam_fan{$rec});
}
sub all_spam_to_exists() {
foreach my $rec (@Recipients) {
return 1 if ( all_spam_to($rec) );
}
return 0;
}
- Then all_spam_to_exists early in filter_begin to decide whether to stream
the message, and call all_spam_to in filter_end to decide whether to run
SpamAssassin.
Then you can remove all_spam_to from local.cf entirely, since it doesn't do
what you want in the first place.
Note: This is untested code - what we use is more complicated, so I've
tried to simplify it, but there may be typos.
Kelson Vibber
SpeedGate Communications <www.speed.net>
More information about the MIMEDefang
mailing list