I've been searching for a resource on how to do this but not having much luck.
I am running a working MTA/MUA that is based on Postfix and Courier with MySQL as a backend for virtual users. I based my system on the following article:
https://help.ubuntu.com/community/PostfixCompleteVirtualMailSystemHowto
It was great up until the empty sections! My SMTP/IMAP setup is working great, and I managed to get SpamAssassin and ClamAV installed as well with some separate documentation I found online.
What I need help with is setting up Postfix to use Procmail as the mailbox_command so that it will work with virtual users. I want to be able to define different Procmail rules for each virtual user separately. I've read the Postfix documentation, and as I understand it the default functionality for mailbox_command will only work for local (non-virtual) users.
Thanks in advance!
UPDATE:
Since this post, I've come to realize that mailbox_command is not tenable. Instead I found a way to do this using transport_maps. Read my own answer below.
Create one global procmailrc, and for each user make a rule like this:
The usual final rule of each file in /etc/procmailrcs/ should then be to pipe the message to deliver(8).
If you have many users and don't want to maintain a file of this nature, then instead consider writing a script that parses the mail headers to figure out which file in /etc/procmailrcs/ is wanted and executes procmail accordingly, and setting that script as your mailbox_command.
This article was of help: http://www.linuxbackups.org/virtual-procmail.
There were two problems I had to overcome. First, the solution calls for a static file to hold the user/transport map. I need a virtual solution. So instead of creating /etc/postfix/transport, my main.cf says:
Here is my mysql_virtual_transport_maps.cf:
So that solved the "virtual" requirement. The other problem is my directory structure is different than the procmailrc.common example. Here is my procmailrc.common:
Hope this helps others that might be trying to do something similar.
-aj