Automatically Add Disclaimers To Outgoing Emails With alterMIME On Fedora 8

Version 1.0
Author: Oliver Meyer <o [dot] meyer [at] projektfarm [dot] de>

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:

# Localize these.

####### Changed From Original Script #######
####### Changed From Original Script END #######

# Exit codes from <sysexits.h>

# 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

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" || \
                    { echo Message content rejected; exit $EX_UNAVAILABLE; }
####### Changed From Original Script END #######

$SENDMAIL "[email protected]" <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:

[email protected]
[email protected]
[email protected]

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:

Examplestreet 1


3.2 Postfix

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

vi /etc/postfix/

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



Share this page:

Suggested articles

5 Comment(s)

Add comment


By: Stefanos Spanoudakis

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:


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`

By: jm


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



By: dulpicate disclaimers on addresses to the same domain

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

By: sidgers

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??

By: Omar

Followed step by step bu it not works on my machine with amavis-new. Don't know where to start debugging. Help please! :(