Add Mailfiltering to the Falko howto Postfix Guide
Add Mailfiltering to the Falko howto Postfix GuideIn this guide, you will learn how to get around some of the security policies that Postfix affords in favour of quickness and speed. The Falko guide shows us how to get Virtual users working with Postfix/ Courier IMAP however it would be nice to offer per user mail filtering on email marked as spam by Spam Assasin for example to go into a SPAM folder for example. This is no easy task like say using the local delivery agent in Postfix where you can make use of .forward files and .procmailrc/.mailfilter files dependant on your mailbox_command. The Falko guide uses the VDA (Virtual Delivery Agent), it gives security and speed but removes the expansion of the .forward files and doesn't use the mailbox_command. One method around this is to replace the Virtual_transport configuration option on Postfix with Maildrop however on any large scale system you might experience slowdown, the VDA is super super fast so lets leave it be and concentrate mail filtering on a per domain / per user basis instead using Maildrop Firstly we need to recompile Maildrop to include virtual user support from MySQL databases (on a note nearly every other Linux distro apart Debian a MySQL version of Maildrop already exists): # cd /usr/local/src# apt-get src maildrop # tar zxvf <tarballname> # cd <dir> # ./configure --enable-maildirquota --prefix=/usr/local/maildrop --enable-maildropmysql --with-mysqlconfig=/etc/maildropmysql.conf --enable-maildrop-uid=5000 --enable-maildrop-gid=5000 --enable-trusted-users="root postfix vmail" --enable-syslog=1# make # make install Points to note 5000 UID/GID refers to the Falko guide, syslogging is essential as Maildrop is troublesome to get going. I am using a prefer of /usr/local/maildrop because I don't want this mucking around with my default Debian, it can be easily removed by a simply rm -rf command at any stage. Maildirquota needs to be enabled because the VDA will no longer be used for this domain, so Maildrop needs to be used to enforce the quota instead of the patched Postfix. Next we need to change the Maildrop entry in /etc/postfix/master.cf It would appear the Debian documentation is crap on Maildrop (anyone trying to do a Horde install will back me up on this one, some things are just not documented clearly) the Maildrop lines needs changes to read: maildrop unix - n n - - pipe Next we add the following into the /etc/postfix/main.cf file: maildrop_destination_recipient_limit=1
# /etc/init.d/postfix restart
# `test -f /u0/vmail/.mailfilters/$LOGNAME` Points to note your vmail directory will be different so you need to change this script and secondly this script makes the directories if they don't already exist. Unlike the VDA, Maildrop cannot make it's own directories without a little help!! Configure Maildrop to get the Directory storage through MySQL: Edit the following file /etc/maildropmysql.conf hostname 127.0.0.1 Points to note: the active field and the "clause" can also be added to courier authlib stuff to allow you to still receive email for a user but not allow them to login. This is brilliant if a custom hasn't paid a bill and you simply want them to be turned off for a few hours whilst they sweat and go pay their bill, otherwise you have to delete the user from the virtual users mailbox and begin boucing mail which isn't the most elegant of solutions. Next we need a slight modification to the original users table provided my the Falko guide: CREATE TABLE users ( added fields "active, uid, gid, maildir'. UID/ GID can be left alone and take a default value of 5000/5000 when adding new users as does the active field. The only field that must be keyed in is the maildir field. Previously the Falko guide does a string concatonation to make up the maildir directory from email address, but Maildrop is so clever so we must specify. Once again none of this is neccessary for domains that will still continue to use the VDA instead of Maildrop.
INSERT INTO `transport` ( `domain` , `transport` ) Next we need a basic Mailfilter to test: In my example mailfilters will be stored in the following location: /u0/vmail/.mailfilter/user@domain.com
logfile "/u0/vmail/.mailfilters/mailfilter-log.txt" if ( /^Subject: SPAM/) This filter sends emails with the word spam to a folder called spam in the users inbox or else all the other mail goes unfiltered and arrives as normal in the main part of the users inbox. If all goes wrong look at the syslog (hence the reason for compiling in support for it as it will help to some degree in make head or tails of whats happening) More to come...how to do maildrop quota as we have just lost the abilty for Postfix to manage it by using this fitler
|
Join the discussion.
www.seamlessenterprise.com
IP Convergence
Integrate your wireless and wireline networks.
Learn how from the experts at Sprint.
www.seamlessenterprise.com
Wireless & Wireline Integration
Thoughts, strategies and solutions: join the discussion
www.seamlessenterprise.com
Unified Communications 2009
Join the Discussion. Now.
www.seamlessenterprise.com




![Creative Commons Attribution License [Creative Commons Attribution License]](http://creativecommons.org/images/public/somerights20.gif)



Recent comments
22 hours 14 min ago
23 hours 43 min ago
1 day 3 hours ago
1 day 6 hours ago
1 day 9 hours ago
1 day 9 hours ago
1 day 10 hours ago
1 day 11 hours ago
1 day 12 hours ago
1 day 12 hours ago