Mar 10

I have qmailtoaster installation so my users are in:

/home/vpopmail/domains/DOMAIN.XXX/USER

you need two create two file:

first called “mailfilter” can be put wherever you want (this file will be in .qmail file), me  I choose:

/home/vpopmail/domains/

so now I have:

/home/vpopmail/domains/mailfilter

second called “.qmail” must be pun in user folder in the same dir with Maildir folder, like this:

/home/vpopmail/domains/MYDOMAIN.XXX/USER/.qmail

File contents are:

.qmail

|preline /usr/bin/maildrop /home/vpopmail/domains/mailfilter

mailfilter

SHELL=”/bin/bash”
import EXT
import HOST
logfile “/var/log/maildrop/mailfilter.log”
USERHOME=`/home/vpopmail/bin/vuserinfo -d $EXT@$HOST`
if (/^Subject:.*\[SPAM\]/:h)
{
log “WE got a SPAM, moving mail to spam directory $USERHOME/Maildir/.Junk”
DUMMY=`test -d $USERHOME/Maildir/.Junk`
#if .Junk folder exists
if ( $RETURNCODE == 0 )
{
to “$USERHOME/Maildir/.Junk”
}
else
{
log “No Junk directory in $USERHOME/Maildir”
to “$USERHOME/Maildir/”
}
}
else
{
to “$USERHOME/Maildir/”
}

This works for users in witch dirs you put .qmail file. If you want for whole domain you must use :

/home/vpopmail/domains/MYDOMAIN.XXX/.qmail-default file instead of .qmail in user directory.

written by MG \\ tags: , , ,