Dan Horne wrote:
I am setting up a new mail server using postfix and maildrop connected
to a MySQL db. I am calling Spamassassin via maildrop using the
following in /usr/local/etc/maildroprc:
if ( $SIZE < 26144 )
{
exception {
xfilter "/usr/bin/spamassassin
--prefspath=$HOME/$DEFAULT/.spamassassin/user_prefs "
}
}
My goal is to somehow be able to check the value of a field in the
database to determine WHETHER to call spamassassin. In other words,
some of my users don't want spam filtering, and I need to figure out how
to "turn it off" for them. My idea is a boolean field in the user db.
Is there any way for this to work? I can't find any information on the
maildrop/mysql integration, specifically the maildropmysql.config file
syntax. I had to comb through multiple HOWTOs to get a working one. Is
there a way to query for extra fields in that file? Alternatively does
anyone know how to perform a query on a mysql db and make the results
available to the maildrop filters?
Try something like the following to load the setting into a environment
variable within maildrop:
RUN_SA=`echo "SELECT value FROM userpref where username = '$USER' and
preference = 'use_sa'" | mysql -s -u dbuser -pdbpass spamassassin`
Assuming your using SQL based SA prefs, now all you need is for users to
create a pref named run_sa and set the value to 0 or 1. The mysql
command line will execute the query and return only the results which
will be placed in $RUN_SA so a simple if ($RUN_SA) would be all you need
past that. you might have to replace $USER (which I believe will be the
full email address in most cases) with $LOCAL. You could also modify
this to store it in another table if you preferred.
Jay