8 messages in net.sourceforge.lists.courier-maildropRe: [maildropl] How to get extra info...
FromSent OnAttachments
Dan HorneSep 28, 2005 2:28 pm 
Jay LeeSep 28, 2005 2:47 pm 
Jay LeeSep 28, 2005 2:49 pm 
Dan HorneSep 29, 2005 6:44 am 
Dan HorneSep 29, 2005 6:45 am 
Jay LeeSep 29, 2005 7:10 am 
Dan HorneSep 29, 2005 7:14 am 
Jay LeeSep 29, 2005 7:17 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [maildropl] How to get extra info from MySQL db into filtersActions...
From:Jay Lee (jl@pbu.edu)
Date:Sep 28, 2005 2:47:13 pm
List:net.sourceforge.lists.courier-maildrop

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