I have setup a working SMTP, IMAP and POP3 server using Postfix and Dovecot. I have setup virtual mailboxes using the format /home/vmail/%d/%u, where %d is the domain (e.g. camilstaps.nl) and %u is the 'user' (e.g. info) - thus has /home/vmail/. I now would like to setup Procmail to use filters.
I have read this wiki, for example, but I don't think it applies to my situation with virtual mailboxes. I have not enough knowledge of Procmail to do this all by myself.
Could anyone explain to me or give me a link where to start? I searched on google but only came across useless forum threads, no documentation or tutorial. That makes me wonder if it's even possible to do this.
21 Answer
WARNING: It should work but I have not tested it myself.
RECOMMENDED IMPROVEMENT: I would advice making both postfix and dovecot use mysql (or another database) to store valid virtual user.
Discussion about procmail script in /etc/procmailrcs/
/etc/postfix/main.cf:
# list of valid/served virtual domains
virtual_mailbox_domains = example.com example.net
# verification of virtual recipient validity
virtual_mailbox_maps = hash:/etc/postfix/virtual
# transport for deliveries to virtual mailboxes
virtual_transport = virtualprocmail:dummy
virtualprocmail_destination_recipient_limit = 1/etc/postfix/virtual (requires compilation with postmap):
Jane Doe John Doe/etc/postfix/master.cf (replace virtualuser with real OS account name owning the virtual mailboxes):
virtualprocmail unix - n n - - pipe flags=DRXhuq user=virtualuser argv=/usr/bin/procmail -m E_SENDER=$sender E_RECIPIENT=$recipient ER_USER=$user ER_DOMAIN=$domain ER_DETAIL=$extension NEXTHOP=$nexthop /etc/procmail.d/default.rc/etc/procmail.d/default.rc (must be readable by virtualuser):
# You should add some sanity chces of ${ER_DOMAIN} and ${ER_USER}
# Add trailing / if you want to use maildir directory instead of mailbox file
DEFAULT=/home/vmail/${ER_DOMAIN}/${ER_USER} 5