One of the main features always missing from Zimbra (When I refer to Zimbra Im always talking about the Open Source Version) was amongst other things, the lack of in-built support for adding disclaimers to the bottom of emails. They would have addressed this in Zimbra 6 Right? Wrong! Whats more, the Domain Disclaimers Admin Extention written by one of the Zimbra Team as an unofficial add on, will not work with Zimbra 6 because they have ditched the ldap based configuration (or something like that).
As a result, there isnt a fancy admin extention for disclaimers (at time of writing) ergo, something a bit more primitive is needed. I wrote a disclaimer script with PHP that reads the disclaimers from an INI file. Its a bit more sophisticated that the standard SH script thats included with the unofficial addon, and supports a couple of customisations.
- First of all, we going to need altermime, download it from http://www.pldaniels.com/altermime/ (Version 0.3.10 at time of writing) Note there are two versions, a paid for version, and an opensource version. The opensource version is fine for our needs
- untar it
tar -zxvf altermime-0.3.10.tar.gz
- Then compile it
cd /altermime-0.3.10
make
make install
- This will install altermime into /usr/bin. So lets set some permissions:
chown root.root /usr/bin/altermime
chmod 755 /usr/bin/altermime
- Now make some folders
mkdir -p /opt/zimbra/postfix/conf/disclaimers
chown zimbra.zimbra /opt/zimbra/postfix/conf/disclaimers
- We need the script that postfix will run when mail is sent. You can download it here. I'd reccomend wget:
cd /opt/zimbra/postfix/conf
wget http://www.lunarhotel.co.uk/downloads/disclaimer.zip
- unzip disclaimer.zip
unzip disclaimer.zip
- Again, lets set some permissions:
chown root.root ./disclaimer.php
chmod 750 ./disclaimer.php
- Now, we need to create an ini file in /opt/zimbra/postfix/conf/disclaimer called disclaimer.ini. It should look like this:
[default]
text="Text version of disclaimer"
html="HTML version of disclaimer"
If your server is the mailserver for multiple domains, you can set per domain disclaimers by making the domain name the section name. E.g.
[yourdomain.com]
text="Text version of yourdomain.com disclaimer"
html="HTML version of yourdomain.com disclaimer"
- And then set permissions on that
chown root.root /opt/zimbra/postfix/conf/disclaimer/disclaimer.ini
- Alls thats left is to adjust the postfix configuration.
Add the following to your master.cf.in just after top line (around line 11).
dfilt unix - n n - - pipe
flags=Rq user=zimbra argv=/opt/zimbra/postfix/conf/disclaimer.php -f ${sender} -- ${recipient}
So it should look like this
smtp inet n - n - - smtpd
-o content_filter=dfilt:
dfilt unix - n n - - pipe
flags=Rq user=zimbra argv=/opt/zimbra/postfix/conf/disclaimer.php -f ${sender} -- ${recipient}
- Finally, restart postfix
su zimbra
zmmtactl stop
zmmtactl start
By default the script is set to add a disclaimer to any email (destined for both internal and external addresses). If you want the disclaimer adding to only outbound mail, set LOCAL_DISCLAIMER to false. Logging is turned off by default. If you want to turn it on, set LOGGING to true. It will log to /var/log/messages.
If your Zimbra is not installed in /opt/zimbra/ you'll need to change the workpath to the correct location.