#!/bin/sh # Localize these. INSPECT_DIR=/var/spool/filter SENDMAIL=/usr/sbin/sendmail # Define our company address lists disclaimer_addresses_companya=/etc/postfix/disclaimer_addresses_companya disclaimer_addresses_companyb=/etc/postfix/disclaimer_addresses_companyb disclaimer_addresses_companyc=/etc/postfix/disclaimer_addresses_companyc disclaimer_addresses_companyd=/etc/postfix/disclaimer_addresses_companyd # Exit codes from 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; } # Obtain From address domain from_address=`grep -m 1 "From:" in.$$ | cut -f 2 -d '@' | cut -d ">" -f 1` # If the from address matches companya then apply the appropiate disclaimed if [ `grep -wi ^${from_address}$ ${disclaimer_addresses_companya}` ]; then /usr/bin/altermime --input=in.$$ \ --disclaimer-html=/etc/postfix/disclaimer_companya.txt || \ { echo Message content rejected; exit $EX_UNAVAILABLE; } # If the from address matches companyb then apply the appropiate disclaimed if [ `grep -wi ^${from_address}$ ${disclaimer_addresses_companyb}` ]; then /usr/bin/altermime --input=in.$$ \ --disclaimer-html=/etc/postfix/disclaimer_companyb.txt || \ { echo Message content rejected; exit $EX_UNAVAILABLE; } # If the from address matches companyc then apply the appropiate disclaimed if [ `grep -wi ^${from_address}$ ${disclaimer_addresses_companyc}` ]; then /usr/bin/altermime --input=in.$$ \ --disclaimer-html=/etc/postfix/disclaimer_companyc.txt || \ { echo Message content rejected; exit $EX_UNAVAILABLE; } # If the from address matches companyd then apply the appropiate disclaimed if [ `grep -wi ^${from_address}$ ${disclaimer_addresses_companyd}` ]; then /usr/bin/altermime --input=in.$$ \ --disclaimer-html=/etc/postfix/disclaimer_companyd.txt || \ { echo Message content rejected; exit $EX_UNAVAILABLE; } fi # Send the email on as per the Postfix stack $SENDMAIL "$@"