[Mimedefang] Spamc/spamd vs standard MD
John Nemeth
jnemeth at victoria.tc.ca
Thu Apr 12 06:28:46 EDT 2007
On Sep 2, 6:28am, Danny Kj=?ISO-8859-1?B?5g==?=rgaard wrote:
}
} I would really like the get the mysql userprefs in SA working. As i
} understand the only way to make this work is to use spamc/spamd is this
} correct?
No. First, you need this code in your filter (which has been
removed from the sample filter) to get $SASpamTester:
# The next lines force SpamAssassin modules to be loaded and rules
# to be compiled immediately. This may improve performance on busy
# mail servers. Comment the lines out if you don't like them.
if ($Features{"SpamAssassin"}) {
spam_assassin_init()->compile_now(1) if defined(spam_assassin_init());
}
You need to do stream_by_recipient() so that you're filtering
recipients individually. You need some way to determine the username
to use in the mysql lookup. I have a function which checks if the
domain is a virtual domain or one of the various aliases for the local
domain (it also downcases the address). In the former case, it uses
the full address. In the latter case, it just uses the username part.
It also does a mysql lookup for "checkspam" to allow individuals to
opt-out of spam scanning. Then you need to adjust your filter_end()
like this:
my($user) = should_check_for_spam($Recipients[0]);
if (defined($user)) {
if ($Features{"SpamAssassin"}) {
if (-s "./INPUTMSG" < 100*1024) {
# Only scan messages smaller than 100kB. Larger messages
# are extremely unlikely to be spam, and SpamAssassin is
# dreadfully slow on very large messages.
$SASpamTester->load_scoreonly_sql($user);
$SASpamTester->signal_user_changed({ username => $user });
my($hits, $req, $names, $report) = spam_assassin_check();
load_scoreonly_sql() tells spamassassin to fetch the user's preferences
from an sql database (without loading things like rules).
signal_user_changed() tells spamassassin what username to use for
bayesian purposes (I also have the bayesian database stored in mysql
{be careful, this can create a very large database -- mysql's ibdata1
is 4G for me}).
Beyond this, I do things like allow the user to specify the Subject:
prefix to use to mark spam, and have a spamassassin score at which the
message will be rejected. Also, I don't check outgoing mail (larts are
used to handle that situation), which is a local policy decision. For
outgoing mail, I don't bother with stream_by_recipient() and have a
check for that case just above the above code snippet.
}-- End of excerpt from Danny Kj=?ISO-8859-1?B?5g==?=rgaard
More information about the MIMEDefang
mailing list