Jorge Salamero Sanz said:
i have a virtual domain system doing the mail delivery with
courier-maildrop. the .mailfilter file now includes a file with per user
rules:
LOGNAME=tolower($LOGNAME)
`test -e $LOGNAME`
if ( $RETURNCODE != 0 ) {
`maildirmake $LOGNAME`
`maildirmake $LOGNAME/._spam`
}
`test -f $LOGNAME/mailfilter`
if ( $RETURNCODE == 0 ) {
include "$LOGNAME/mailfilter" }
if ( /^X-Spam-Status: YES */) {
to "$LOGNAME/._spam" }
else {
to "$LOGNAME/" }
now i'd like to have these rules in a mysql db so each user could edit
his rules thru a simple web frontend.
Interesting idea, I'd never thought of this. Would make modify rules much
easier since their in a db and no need to worry about FS permissions, etc.
what do you think should be the best way to do this ?
a perl script querying the database included in each user filter rules ?
modify maildrop source to query the database ?
thanks !
I would say have mysql cli pull the rules from the global maildroprc file,
then there is no need to create indiv. user .mailfilter files:
`echo "SELECT mailfilter FROM users where username = '$USER'" | mysql -s
-u myuser -pmypass mydatabase > $HOME/myfilter`
exception {
include "$HOME/myfilter"
}
`rm -f $HOME/myfilter`
This should pull the rules out of mysql each time, write them to myfilter
file, execute and then remove the rules. The one problem I can see with
this code is two deliveries by maildrop to the same account in which case
myfilter will get hit, so you should figure out a way to make the name
unique each time, that way two maildrop processes will not be contending
for the same file.