Automatically Add Disclaimers To Outgoing Emails With alterMIME On Fedora 8

Want to support HowtoForge? Become a subscriber!
 
Submitted by o.meyer (Contact Author) (Forums) on Fri, 2008-02-22 17:16. :: Fedora | Email | Postfix

Automatically Add Disclaimers To Outgoing Emails With alterMIME On Fedora 8

Version 1.0
Author: Oliver Meyer <o [dot] meyer [at] projektfarm [dot] de>
Last edited 02/19/2008

This document describes how to install and configure alterMIME as a Postfix filter on a Fedora 8 system. The resulting system will automatically add disclaimers to outgoing emails.

This howto is a practical guide without any warranty - it doesn't cover the theoretical backgrounds. There are many ways to set up such a system - this is the way I chose.

 

1 Preliminary Note

A running (and properly configured) Postfix server is required for this setup.

 

2 Needed Package

yum -y install altermime

 

3 Configuration

3.1 Altermime

First we create a system-account for altermime.

useradd -r -c "Postfix Filters" -d /var/spool/filter filter
mkdir /var/spool/filter
chown filter:filter /var/spool/filter
chmod 750 /var/spool/filter

Next we create a script that'll execute altermime.

vi /etc/postfix/disclaimer

It should look like this:

#!/bin/sh
# Localize these.
INSPECT_DIR=/var/spool/filter
SENDMAIL=/usr/sbin/sendmail.postfix

####### Changed From Original Script #######
DISCLAIMER_ADDRESSES=/etc/postfix/disclaimer_addresses
####### Changed From Original Script END #######

# 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; }

####### Changed From Original Script #######
# obtain From address
from_address=`grep -m 1 "From:" in.$$ | cut -d "<" -f 2 | cut -d ">" -f 1`

if [ `grep -wi ^${from_address}$ ${DISCLAIMER_ADDRESSES}` ]; then
  /usr/bin/altermime --input=in.$$ \
                   --disclaimer=/etc/postfix/disclaimer.txt \
                   --disclaimer-html=/etc/postfix/disclaimer.txt \
                   --xheader="X-Copyrighted-Material: Please visit http://www.company.com/privacy.htm" || \
                    { echo Message content rejected; exit $EX_UNAVAILABLE; }
fi
####### Changed From Original Script END #######

$SENDMAIL "$@" <in.$$
exit $?

Afterwards change the group and the rights in order that altermime is allowed to execute the script.

chgrp filter /etc/postfix/disclaimer
chmod 750 /etc/postfix/disclaimer

Note: This script has been modified by Falko - disclaimers will only be added to outgoing mails.

Now create a file that contains all sender email addresses which will be processed by altermime.

vi /etc/postfix/disclaimer_addresses

This is an example how it should look like:

olli@example.com
falko@example.com
till@example.com

Last but not least create a file that contains the disclaimer text. Edit it as you like.

vi /etc/postfix/disclaimer.txt

For example - it could look like this:

-------------------
EXAMPLE Company
Examplestreet 1
Examplecity

www.example.com

 

3.2 Postfix

Now you have to tell Postfix that it should use altermime to add disclaimers to mails.

vi /etc/postfix/master.cf

Add the line "-o content_filter=dfilt:" (without the quotes) straight below the line for smtp. Keep in mind, that the new line has to begin with at least one whitespace.

The corresponding part should look like this:

smtp      inet  n       -       n       -       -       smtpd
     -o content_filter=dfilt:

Add the following lines at the end of the file. Keep in mind, that the line with the flags (flags=...) has to begin with at least one whitespace.

# altermime
dfilt unix - n n - - pipe flags=Rq user=filter argv=/etc/postfix/disclaimer -f ${sender} -- ${recipient}

Afterwards restart Postfix.

/etc/init.d/postfix restart

 

4 Links

Fedora: http://fedoraproject.org/
alterMIME: http://pldaniels.com/altermime/


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by sidgers (not registered) on Sun, 2009-07-12 15:45.
I used this writeup on my Fedora 8 machine and it works like a charm.  Is there any way to add the disclaimer to all outgoing messages irrespective of the sender's e-maill address??
Submitted by Stefanos Spanoudakis (not registered) on Fri, 2009-04-10 20:00.

If you need to match all the senders from your domain and not just specific ones do the following:

in the file /etc/postfix/disclaimer_addresses add your domains like:

example.com

sub.example.com

 

and then change the following line at /etc/postfix/disclaimer script:

original: from_address=`grep -m 1 "From:" in.$$ | cut -d "<" -f 2 | cut -d ">" -f 1`

after the change: from_address=`grep -m 1 "From:" in.$$ | cut -d "<" -f 2 | cut -d ">" -f 1 | cut -d "@" -f 2`

Submitted by dulpicate discl... (not registered) on Sat, 2011-04-16 09:38.

This works great apart from when an email is sent to another recipient within the same domain as the sender - the recipient will get the disclaimer twice. Any idea how to get around this? Thanks

Submitted by jm (not registered) on Wed, 2010-11-17 13:30.

Hi,

 Email Disclaimer works fine now with my MS Outlook. Problem is that the calendar invitation becomes garbled. How can I fix that?

 

Thanks