Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mjf/2e596f1a55dd8a47ef324d336e40ebb7 to your computer and use it in GitHub Desktop.
Save mjf/2e596f1a55dd8a47ef324d336e40ebb7 to your computer and use it in GitHub Desktop.
Add Custom Local Parameters for Zimbra Postfix Configuration

Add Custom Local Parameters for Zimbra Postfix Configuration

We will add two custom local parameters:

  • sender_bcc_maps
  • recipient_bcc_maps

so that we could define our own per-user Bcc: forwarding for all users in a domain (also see this Gist to know more generally about how to configure it for Postfix).

sudo -iuzimbra vi conf/zmconfigd.cf

Open the file /opt/zimbra/conf/zmconfigd.cf in your favourite $EDITOR and find line stating RESTART mta in it (it should be located in a section SECTION mta DEPENDS ... or similar). Then add the following two lines just before that line so that it will look like this.

    POSTCONF sender_bcc_maps    LOCAL custom_postfix_sender_bcc_maps
    POSTCONF recipient_bcc_maps LOCAL custom_postfix_recipient_bcc_maps
    RESTART mta

The two lines states that sender_bcc_maps and recipient_bcc_maps in Postfix configuration that will be generated by Zimbra will possess values configured via zmlocalconfig -e (the LOCAL keyword makes this) called custom_postfix_sender_bcc_maps and custom_postfix_recipient_bcc_maps respectively.

Once having this done you can set the values using the zmlocalconfig -e as follows (under the zimbra user):

sudo -iuzimbra zmlocalconfig -e 'custom_postfix_sender_bcc_maps=pcre:/opt/zimbra/conf/postfix_domain_users_bcc_maps'
sudo -iuzimbra zmlocalconfig -e 'custom_postfix_recipient_bcc_maps=pcre:/opt/zimbra/conf/postfix_domain_users_bcc_maps'

(There MUST NOT be any whitespace around the = / equal sign!)

Note: Because in this very case we want both Bcc: rulesets to be exactly the same we use the same file for both the maps. You can, of course, set different maps files for each. :-)

Now you can restart the Zimbra's MTA service which will yield Postfix configuration regeneration as well:

sudo -iuzimbra zmmtactl restart

Review if everything is set as expected:

sudo -iuzimbra zmlocalconfig |grep -E 'custom_postfix_'
sudo -iuzimbra postconf |grep -E '(sender|recipient)_bcc_maps'

Note: I guess you will have to do the editing after each Zimbra update so this method is very, very unreliable and error-prone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment