Zarafa, Postfix and Procmail with virtual users
From Zarafa wiki
This article is a community contribution and may include unsupported configurations.
Introduction
This howto describes setting up Zarafa with Postfix and Procmail for users without a home directory. This howto is closely based on the forum posting (http://forums.zarafa.com/viewtopic.php?f=11&t=2759).
Postfix
Adjustments to Postfix main.cf
/etc/postfix/main.cf
virtual_transport = procmail: mailbox_transport = procmail: # be sure to only deliver to procmail one user at a time: procmail_destination_recipient_limit = 1 # we use virtual_alias_* to redirect mails for local postmaster/root etc. to another server: virtual_alias_maps = hash:/etc/postfix/virtual # replace THISHOST with your host FQDN (example: zarafa1.foo.bar) virtual_alias_domains = THISHOST # the SQL file needs the Zarafa query for users virtual_mailbox_maps = mysql:/etc/postfix/zarafa-users.sql, hash:/etc/postfix/virtual # the SQL file needs the Zarafa query for domains virtual_mailbox_domains = mysql:/etc/postfix/zarafa-domains.sql virtual_minimum_uid = 500 virtual_uid_maps = static:500 virtual_gid_maps = static:500
/etc/postfix/master.cf
procmail unix - n n - - pipe flags=DORX user=vmail argv=/usr/bin/procmail -t -o SENDER=${sender} -m USER=${user}@${domain} DOMAIN=${domain} EXTENSION=${extension} RECIPIENT=${recipient} /etc/procmailrc
This sets the variables SENDER, USER, DOMAIN, EXTENSION, RECIPIENT for use within the procmailrc script. See "man procmailrc" for explanation, if it's not already clear what they mean.
Attention: According to the procmail manpage, you should write "..procmail ... -m /etc/procmail USER.. (all the flags)", but then you need to take care to have a space as the last character, otherwise procmail will create "dsn=5.3.0, status=bounced (command line usage error)" for whatever reason. The "flags=DORX" is explained in "man pipe" from postfix.
Attention: Our users are named after their e-mail address, like [email protected], that's why we set USER to [email protected]$domain. We can't use $recipient, as that could be [email protected], so the procmail script wouldn't work anymore.
Procmail
/etc/procmailrc
SHELL=/bin/bash LOGFILE=/var/log/procmail VERBOSE=on # debugging: remove "#" from the beginning of the line #LOG="DOMAIN=$DOMAIN, USER=$USER, SENDER=$SENDER, EXTENSION=$EXTENSION" ############################################################################################ # Domain Filter ############################################################################################ :0 * $DOMAIN ?? our.domain.example { # this filters SPAM to the junk box in Zarafa for all users in this domain :0w * ^X-Spam-Flag: yes | /usr/bin/zarafa-dagent -j $USER EXITCODE=$? } ############################################################################################ # User Filter ############################################################################################ :0 * $USER ?? [email protected] { # mail that arrived at the spamtrap is filtered to this box. # Remember: \\ is the folder separation! # Remember: X-Original-To: is only inserted when you have single recipient delivery, and procmail was called with flags=O :0w * ^X-Original-To: [email protected] | /usr/bin/zarafa-dagent $USER -CF Inbox\\SPAM_trapped EXITCODE=$? } ############################################################################################ # Default/Fallback Action ############################################################################################ :0w | /usr/bin/zarafa-dagent $USER EXITCODE=$?
Remember that flags=DORX is important for procmail in master.cf, it gives you a lot of needed info into headers. Don't forget to setup single recipient delivery in main.cf, otherwise procmail will do a mess.
Of course you'll want to expand /etc/procmailrc, this is just a basic example and good for first testings. Look into /var/log/procmail for filtering details. Set verbose=off if no logging needed.