Postfix does not support putting a disclaimer or footer on outgoing email messages. To do this you have to inject a bit of extra code to make
it work. There are decent articles that does this but they do not do this on a domain basis (rather it does a mailbox by mailbox basis). Also
every time a message in a to/reply/reply/reply scenario is generated the disclaimer gets added on each turn around of the message
which is somewhat tedious. The decent articles if you search the web.A set we used that follow the same theme
are here and
especially here.
Below is our modified script to ensure all mail boxes for a domain or set
of domains have footers added and our footer is only inserted once.
#!/bin/sh
# Consulting Ian Tighe and others 2009
INSPECT_DIR=/var/spool/filter
SENDMAIL=/usr/sbin/sendmail.postfix
DISCLAIMER_ADDRESSES=/etc/postfix/disclaimer_addresses
#
# 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
cd $INSPECT_DIR || { "echo $INSPECT_DIR does not exist" >> /var/spool/filter/log; exit
$EX_TEMPFAIL; }
cat >in.$$ || { echo "Cannot save mail to file" >> /var/spool/filter/log; exit $EX_TEMPFAIL; }
#
# if the email already has a disclaimer of our then do not add another one. Skip everything and send the email back.
#
if [ -z `grep -m 1 "* CONFIDENTIALITY, PRIVACY, COPYRIGHT AND SECURITY NOTICE *" in.$$ |awk '{print $3}'` ]
then
#
# obtain From mailbox and domain from the mail message being sent
#
from_domain=`grep -m 1 "From:" in.$$ | cut -d "<" -f 2 | cut -d ">" -f 1 | cut -d "@" -f 2`
from_mailbox=`grep -m 1 "From:" in.$$ | cut -d "<" -f 2 | cut -d ">" -f 1 `
#
# Get and process the address file data -
# Record format is domain or mailbox name and optional disclaimer file name and optionally a web link.
# Do mailbox first to get to the most granular possibility first
#
server_mailbox=`grep -i ^${from_mailbox} ${DISCLAIMER_ADDRESSES} | awk '{print $1}'`
server_domain=`grep -i ^${from_domain} ${DISCLAIMER_ADDRESSES} | awk '{print $1}'`
if [ ! -z $server_mailbox ]
then
from=$server_mailbox
elif [ ! -z $server_domain ] then
from=$server_domain
else
#echo `date` >> /var/spool/filter/log
#echo "Nothing found. Not all domains and mailboxes use disclaimers.Passing email on." >> /var/spool/filter/log
#echo "Debug: $from_domain,$from_mailbox,$server_mailbox,$server_domain,$from" >> /var/spool/filter/log
$SENDMAIL "$@" <in.$$;
exit $?
fi
#
# set a default disclaimer file if none stated. Set default if stated disclaimer file does not exist.
#
disclaimer_filename=`grep -i ^${from} ${DISCLAIMER_ADDRESSES} | awk '{print $2}'`
if [ -z $disclaimer_filename ]
then
disclaimer_filename="/etc/postfix/disclaimer.txt"
elif [ ! -r $disclaimer_filename ]
then
disclaimer_filename="/etc/postfix/disclaimer.txt"
fi
#
# Set copyright tag header information per mailbox or per domain
#
copyright=`grep -i ^${from} ${DISCLAIMER_ADDRESSES} | awk '{print $3}'`
if [ -z $copyright ]
then
copyright="http://www.renegade-hosting.co.uk"
fi
#
# alter the email
#
/usr/bin/altermime --input=in.$$ --disclaimer=$disclaimer_filename \
--disclaimer-html=$disclaimer_filename \
--xheader="X-Copyrighted-Material: Please visit $copyright" || \
{ echo Message content rejected; exit $EX_UNAVAILABLE; }
fi
#
# send the altered email
#
$SENDMAIL "$@" <in.$$;
exit $?
Our address file looks like this:
domain1.com /users/web/joe/disclaimer.txt http://www.domain1.com
domain2.co.uk
bill@domain2.net /users/web/bill/disc.txt
Our disclaimer.txt looks like this:
_________________________________________________________________________________________________________________________________
* CONFIDENTIALITY, PRIVACY, COPYRIGHT AND SECURITY NOTICE *
This mail is confidential to the adressee only and any other use of it is unauthorised.
If you are not the adressee and you receive it by accident or otherwise please destroy it
and notify the sender of such. To act on it or disminate any of its contents on an unauthorised
basis may be a criminal offence and you leave youself open to prosecution. All the material
in this email is Copyright. The presence of this notice applies to all parts of this entire email whether those elements
pre or post date the insertion of this message.
This mail has been scanned by Consulting Ian Tighe @ renegade-hosting.co.uk and was free of
viruses and harmful objects when dispatched.
Great care has been taken to try and reassure you that this email is genuine. DKIM and SPF
techniques are used to allow your mail server to assure you this is a bone fide email. We promote
these methods and would encourage your technical team to adopt them to help reduce spam and harmful emails.
__________________________________________________________________________________________________________________________________
Finally
Note that the scripts searches for the key phrase in the disclaimer.txt file to see
if the message alreay contains a disclaimer. You
would need to change this for whatever pharse you choose in your text file.
When we added the user "filter" we made it so that it could not be logged into.