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:

#!/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:

[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:

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

 

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

Share this page:

5 Comment(s)