Adding a disclaimer (altermime) or footer
From Zimbra :: Wiki
Note: This article adds footer text to all mails sent by Zimbra users.
See also the very cool http://wiki.zimbra.com/index.php?title=Domain_Disclaimer_Extension_Admin_UI
Altermime
- 1) Download altermime from http://www.pldaniels.com/altermime/
- 2) Compile
make
- 3) Install altermime
cp altermime /usr/bin/ chown root.root /usr/bin/altermime chmod 755 /usr/bin/altermime
- 4) Add a "filter" user
useradd -r -c "Postfix Filters" -d /var/spool/filter filter
- 5) Create a filter directory
mkdir /var/spool/filter chown filter.filter /var/spool/filter chmod 750 /var/spool/filter
Postfix
- 6) Backup you master.cf file
cp /opt/zimbra/postfix/conf/master.cf /opt/zimbra/postfix/conf/master.cf.orig
- 7) Modify /opt/zimbra/postfix/conf/master.cf (/opt/zimbra/postfix/conf/master.cf.in for version > 5.0.10)
smtp inet n - n - - smtpd
-o content_filter=dfilt:
dfilt unix - n n - - pipe
flags=Rq user=filter argv=/opt/zimbra/postfix/conf/disclaimer -f ${sender} -- ${recipient}
- 7a) OPTION. To ensure disclaimer is added only to outbound mail:
192.168.0.1:smtp inet n - n - - smtpd
192.168.0.2:smtp inet n - n - - smtpd
-o content_filter=dfilt:
127.0.0.1:smtp inet n - n - - smtpd
-o content_filter=dfilt:
dfilt unix - n n - - pipe
flags=Rq user=filter argv=/opt/zimbra/postfix/conf/disclaimer -f ${sender} -- ${recipient}
The first IP (192.168.0.1) should be the Incoming IP of the Zimbra server.
The second IP (192.168.0.2) should be the Outgoing IP of the Zimbra server.
- 8) Create a disclaimer file in /opt/zimbra/postfix/conf/disclaimer.txt and disclaimer.html
For example:
/opt/zimbra/postfix/conf/disclaimer.txt
_____________________________________________________________________ This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company. Finally, the recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. Company X, Suite# 1, Street, City, Country, www.company.com
/opt/zimbra/postfix/conf/disclaimer.html
_____________________________________________________________________<br> <br> This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed.<br> If you have received this email in error please notify the system manager. Please note that any views or opinions presented in this email are solely <br> those of the author and do not necessarily represent those of the company. Finally, the recipient should check this email and any attachments for <br> the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.<br> <br> Company X, Suite# 1, Street, City, Country, <a href="http://www.company.com"><b>www.company.com<b></a><br>
- 9) Create disclaimer script in /opt/zimbra/postfix/conf/disclaimer
#!/bin/sh
INSPECT_DIR=/var/spool/filter
SENDMAIL=/opt/zimbra/postfix/sbin/sendmail
FOLDER_DISCLAIMER=/opt/zimbra/postfix/conf
# Exit codes from <sysexits.h>
EX_TEMPFAIL=75
EX_UNAVAILABLE=69
# Clean up when done or when aborting.
trap "rm -f in.$$" 0 1 2 3 15
# Start processing.
cd $INSPECT_DIR || { echo $INSPECT_DIR does not exist; exit $EX_TEMPFAIL; }
TEXT_DISCLAIMER=`grep "[a|A-z|Z]" ${FOLDER_DISCLAIMER}/disclaimer.txt | grep -v "_" | tail -2 | head -1`
cat > in.$$ || { echo Cannot save mail to file; exit $EX_TEMPFAIL; }
nohup grep "${TEXT_DISCLAIMER}" in.$$ > /dev/null 2>&1
if [ ! "$?" = 0 ]; then
/usr/bin/altermime --input=in.$$ --disclaimer=${FOLDER_DISCLAIMER}/disclaimer.txt --disclaimer-html=${FOLDER_DISCLAIMER}/disclaimer.html \
--xheader="X-Copyrighted-Material: Please visit www.company.com/privacy.htm" || { echo Message content rejected; exit $EX_UNAVAILABLE; }
fi
$SENDMAIL -i "$@" < in.$$
exit $?
- 10) Set permissions
chgrp filter /opt/zimbra/postfix/conf/disclaimer chmod 750 /opt/zimbra/postfix/conf/disclaimer
- 11) Restart Zimbra postfix
su - zimbra zmmtactl stop zmmtactl start
Good luck!
--
Daniel Eugenin M.
IT Linux Ltda.
Update: Adding a diferent disclaimer by domain
Only you must change:
- 8) Create an disclaimer file per domain and an empty file:
For example:
mkdir /opt/zimbra/postfix/conf/disclaimers /opt/zimbra/postfix/conf/disclaimers/domain1.txt /opt/zimbra/postfix/conf/disclaimers/domain2.txt /opt/zimbra/postfix/conf/disclaimers/emptydisclaimer.txt
- 9) Create disclaimer script in /opt/zimbra/postfix/conf/disclaimer
- !/bin/sh
INSPECT_DIR=/var/spool/filter
SENDMAIL=/opt/zimbra/postfix/sbin/sendmail
LOCAL_DOMAIN1=domain1.com
LOCAL_DOMAIN2=domain2.com
RECIP=`echo $* | awk '{print $NF}'| tr [A-Z] [a-z]`
RECIP_DOMAIN=`echo $RECIP | awk -F"@" '{print $2}'`
SENDER=`echo $* | awk '{print $2}'| tr [A-Z] [a-z]`
SEND_DOMAIN=`echo $SENDER | awk -F"@" '{print $2}'`
# Exit codes from <sysexits.h>
EX_TEMPFAIL=75
EX_UNAVAILABLE=69
# Clean up when done or when aborting. trap "rm -f in.$$" 0 1 2 3 15
# Start processing.
cd $INSPECT_DIR || { echo $INSPECT_DIR does not exist; exit $EX_TEMPFAIL; }
cat > in.$$ || { echo Cannot save mail to file; exit $EX_TEMPFAIL; }
if [ "$RECIP_DOMAIN" = "$SEND_DOMAIN" ]; then /usr/bin/altermime --input=in.$$ \
--disclaimer=/opt/zimbra/postfix/conf/disclaimers/emptydisclaimer.txt \
--disclaimer-html=/opt/zimbra/postfix/conf/disclaimers/emptydisclaimer.txt \
--xheader="X-Copyrighted-Material:" || \
{ echo Message content rejected; exit $EX_UNAVAILABLE; }
elif [ "$SEND_DOMAIN" = "$LOCAL_DOMAIN2" ]; then /usr/bin/altermime --input=in.$$ \
--disclaimer=/opt/zimbra/postfix/conf/disclaimers/domain2.txt \
--disclaimer-html=/opt/zimbra/postfix/conf/disclaimers/domain2.txt \
--xheader="X-Copyrighted-Material: Please visit http://www.domain2.com/privacy.htm" || \
{ echo Message content rejected; exit $EX_UNAVAILABLE; }
elif [ "$SEND_DOMAIN" = "$LOCAL_DOMAIN1" ]; then
/usr/bin/altermime --input=in.$$ \
--disclaimer=/opt/zimbra/postfix/conf/disclaimers/domain1.txt \
--disclaimer-html=/opt/zimbra/postfix/conf/disclaimers/domain1.txt \
--xheader="X-Copyrighted-Material: Please visit http://www.domain1.com/privacy.htm" || \
{ echo Message content rejected; exit $EX_UNAVAILABLE; }
else
/usr/bin/altermime --input=in.$$ \
--disclaimer=/opt/zimbra/postfix/conf/disclaimers/emptydisclaimer.txt \
--disclaimer-html=/opt/zimbra/postfix/conf/disclaimers/emptydisclaimer.txt \
--xheader="X-Copyrighted-Material: " || \
{ echo Message content rejected; exit $EX_UNAVAILABLE; }
fi
$SENDMAIL "$@" <in.$$ exit $?
Addition by:
Rajesh Kodali,
--
Daniel Eugenin M.
IT Linux Ltda.
| Verified Against: | Date Created: 10/1/2006 |
| Article ID: http://wiki.zimbra.com/index.php?title=Adding_a_disclaimer_%28altermime%29_or_footer | Date Modified: 10/1/2009 |
