I finally got maildrop to work for content filtering within a postfix virtual domain, vitrual user e-mail server… Some key points that I had to overcome are:
-
maildrop is now in the ‘epel’ repositories. Many thanks for doing this.
-
The computer user for all virtual users is ‘vmail’
-
The layout for the virtual users is
/home/vmail/[domain.com]/[user]/Maildir -
The main.cf must contain
virtual_transport = maildrop
maildrop_destination_recipient_limit = 1
home_mailbox = Maildir/ -
The master.cf must contain
maildrop unix - n n - - pipe
flags=ODRhu user=vmail argv=/usr/bin/maildrop
-d vmail ${user} ${domain}
The above is different than the documentation and was the key to making maildrop perform. What is documented is
maildrop unix - n n - - pipe
flags=ODRhu user=vmail argv=/usr/bin/maildrop
-d ${user}@${domain} ${extension} ${recipient} ${user} ${nexthop}
- There must be a file
/etc/maildroprc
DEFAULT=“$HOME/$2/$1/Maildir/”
MAILDIR=“$HOME/$2/$1/Maildir”
SHELL=/bin/bash # default shell is usually /bin/sh
logfile “$HOME/$2/$1/maildrop.log”
user=“$1”
domain=“$2”
echo “B Retcde=$RETURNCODE”
log “B Retcde=$RETURNCODE”
system ‘/bin/test -r $HOME/$2/$1/.mailfilter’
if( $RETURNCODE == 1 )
{
exception {
# The log entries have to be before the include file because if there is a
# match in the include file maildrop finishes and log entries would not be
# made if the log command goes after the include file.
echo "include : $HOME/$2/$1/.mailfilter"
log "include : $HOME/$2/$1/.mailfilter"
echo "C RtCd : $RETURNCODE"
log "C RtCd : $RETURNCODE"
}
}
echo “A Retcd=$RETURNCODE”
log “A Retcd=$RETURNCODE”
I have maildroprc owned by root using 644 as the protection
- For the virtual users that wnat that want content filtering a file labeled as .mailfilter should be created in the same directory as the directory Maildir/
/home/vmail/[domain.com]/[user]/.mailfilter
This file should be owned by ‘vmail’ with a group of ‘mail’ with a protection of 600
It should contain teh content filtering rules like
#Spam
if (/^Subject:.[SPAM]*/:H)
{
to “$HOME/$2/$1/Maildir/.Spam”
}
if (/^Subject:.***SPAM*** */:H)
{
to “$HOME/$2/$1/Maildir/.Spam”
}
- I found it very hlpe to use teh maildrop command on teh command line to debug what variables it was using
maildrop -V 10 -d vmail [domain.com] [virtual.user] < /etc/maildrop.test
Good Luck to the next person that uses maildrop to replace procmail for virtual users
Greg Ennis