Zarafa, Postfix and Procmail with virtual users

From Zarafa wiki

(Difference between revisions)
Jump to: navigation, search
(New page: This howto describes setting up Zarafa with Postfix and Procmail for users without a home directory. This howto is closely based on a board post (http://forums.zarafa.com/viewtopic.php?f=1...)
 
(4 intermediate revisions not shown)
Line 1: Line 1:
-
This howto describes setting up Zarafa with Postfix and Procmail for users without a home directory. This howto is closely based on a board post (http://forums.zarafa.com/viewtopic.php?f=11&t=2759) of Michael Monnerie from IT-Management (it-management.at) an austrian partner of Zarafa.
+
<BR>
 +
<font color=red>'''This article is a community contribution and may include unsupported configurations.''' </font>
 +
<BR><BR>
 +
=== 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 ===
=== Postfix ===
Line 22: Line 27:
/etc/postfix/master.cf
/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
+
  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.
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.
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.
The "flags=DORX" is explained in "man pipe" from postfix.
 +
Attention: Our users are named after their e-mail address, like this.user@our.domain.example, that's why we set USER to $user@$domain. We can't use $recipient, as that could be this.user+mailbox@our.domain.example, so the procmail script wouldn't work anymore.
Attention: Our users are named after their e-mail address, like this.user@our.domain.example, that's why we set USER to $user@$domain. We can't use $recipient, as that could be this.user+mailbox@our.domain.example, so the procmail script wouldn't work anymore.

Latest revision as of 13:17, 11 September 2009


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 this.user@our.domain.example, that's why we set USER to $user@$domain. We can't use $recipient, as that could be this.user+mailbox@our.domain.example, 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 ?? this.user@our.domain.example
{
# 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: spam-trap@otherdomain.example
       | /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.

Personal tools