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

And here is the last bit you'll need


As the root user execute the following to test maildrop
Code:
# echo "test" | maildrop -V 9 -d you@example.com
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
Code:
# su mailusr
> echo "test" | maildrop -V 9 -d you@example.com
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 master.cf file from postfix
comment out all the spamassassin stuff and uncomment maildrop and make the required changes
Code:
# vim /usr/local/etc/postfix/master.cf
##    -o content_filter=spamassassin
maildrop  unix  -       n       n       -       -       pipe
  flags=DRhu user=mailusr argv=/usr/local/bin/maildrop -d ${recipient} ${recipient}
##SpamAssassin
##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 main.cf file of postfix
Code:
# vim /usr/local/etc/postfix/main.cf
##virtual_transport = virtual
virtual_transport = maildrop
##spamassassin_destination_recipient_limit = 1
maildrop_destination_recipient_limit = 1
Next go and make a change in MySQL
Code:
# mysql -p
mysql> use postfix;
mysql> UPDATE domain SET transport = 'maildrop' WHERE domain = 'example.com';
mysql> exit
Now restart postfix and have a look in your maillog for any errors.
Code:
# /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.
Code:
# 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.
Code:
# touch vim /usr/local/virtual/mailfilters/you@exmaple.com
# chown postfix:postfix /usr/local/virtual/mailfilters/you@exmaple.com
# vim /usr/local/virtual/mailfilters/you@exmaple.com
# FreeBSD Questions
if (/^X-BeenThere:.*freebsd-questions@freebsd.org/)
{
    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
hamba
Reply With Quote