View Single Post
  #3   (View Single Post)  
Old 7th May 2008
hamba hamba is offline
Fdisk Soldier
Join Date: Apr 2008
Posts: 71

And here is the last bit you'll need

As the root user execute the following to test maildrop
# echo "test" | maildrop -V 9 -d
If there are no errors go and have a look in your inbox, there should be the email you just send.

Next login as the mailusr and run maildrop again
# su mailusr
> echo "test" | maildrop -V 9 -d
If by this stage you get an error then go back and check the permissions of the files.
If you didn't get any errors and you\'ve got the email in your inbox then it means that maildrop is working perfectly and its time to intergrade it into postfix

Go and edit the file from postfix
comment out all the spamassassin stuff and uncomment maildrop and make the required changes
# vim /usr/local/etc/postfix/
##    -o content_filter=spamassassin
maildrop  unix  -       n       n       -       -       pipe
  flags=DRhu user=mailusr argv=/usr/local/bin/maildrop -d ${recipient} ${recipient}
##spamassassin unix -     n       n       -       -       pipe
##        user=nobody argv=/usr/local/bin/spamc -u ${recipient} -f -e
##        /usr/sbin/sendmail -oi -f ${sender} ${recipient}
Next go and edit the file of postfix
# vim /usr/local/etc/postfix/
##virtual_transport = virtual
virtual_transport = maildrop
##spamassassin_destination_recipient_limit = 1
maildrop_destination_recipient_limit = 1
Next go and make a change in MySQL
# mysql -p
mysql> use postfix;
mysql> UPDATE domain SET transport = 'maildrop' WHERE domain = '';
mysql> exit
Now restart postfix and have a look in your maillog for any errors.
# /usr/local/etc/rc.d/postfix restart
Here is the .mailfilter file I use globaly
It will be used for including user based .mailfilter files based on there email address, it also scans for spam and if it comes across any spam it will look for a Junk mail folder in the users maildir and if its not there it will create it for them and then move all the spam emails into it.
# vim /usr/local/virtual/.mailfilter
# My Global maildrop filter
xfilter "/usr/local/bin/spamc -u $1"

# Check for user defined filter file
exception {
    include "$HOME/mailfilters/$1"

# Deliver to Inbox or Spam box (create spam box if it does not exist)
if (/^X-Spam-Flag: YES/:h)
    `test -d $DEFAULT/.Junk`
    if ($RETURNCODE == 1)
        `/usr/local/bin/maildirmake -f Junk $DEFAULT`
        `echo "Junk" >> $DEFAULT/subscriptions`
    exception {
        to "$DEFAULT/.Junk"
    # if all else fails, do regular delivery
    exception {
        to "$DEFAULT"
All the user based .mailfilter files will be under the mailfilter folder in email address format.
# touch vim /usr/local/virtual/mailfilters/
# chown postfix:postfix /usr/local/virtual/mailfilters/
# vim /usr/local/virtual/mailfilters/
# FreeBSD Questions
if (/^X-BeenThere:.*
    to "$DEFAULT/.Questions"
In this users mailfilter it will move all the emails coming in from the freebsd questions maillist to a folder called .Questions

Thats it for now, happy mailling

If you find any problems, and I'm sure there will be, feel free to ask.

Have fun
Reply With Quote