DKIM Keeps Failing When Adding Disclaimer

1 post / 0 new
#1 Wed, 03/27/2019 - 02:46
jeremysmith881

DKIM Keeps Failing When Adding Disclaimer

I have a problem here I am not sure how to go about fixing it.

I went on here after getting the dkim disclaimer/signature script I have been playing around with working for the first ever time on a per domain basis (not too bothered about selecting users as I want all users to have the same domain signature, but there to be different ones as per each domain).

I have this as a script:

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

# For multiple domains:
DOMAIN_A_ADDRESSES=/etc/postfix/domain_a_addresses
DOMAIN_B_ADDRESSES=/etc/postfix/domain_b_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

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

from_domain=`grep -m1 "^From: " in.$$ | cut -f 2 -d "@" | cut -d ">" -f 1`

# hsmedia.co.uk domain name disclaimer
if [ `grep -wi ^${from_domain}$ ${DOMAIN_A_ADDRESSES}` ]; then
  /usr/bin/altermime --input=in.$$ \
                   --disclaimer=/etc/postfix/domain_a_disclaimer.txt \
                   --disclaimer-html=/etc/postfix/domain_a_disclaimer.txt.html || \
                    { echo Message content rejected; exit $EX_UNAVAILABLE; }
fi

if [ `grep -wi ^${from_domain}$ ${DOMAIN_B_ADDRESSES}` ]; then
  /usr/bin/altermime --input=in.$$ \
                   --disclaimer=/etc/postfix/domain_b_disclaimer.txt \
                   --disclaimer-html=/etc/postfix/domain_b_disclaimer.txt.html || \
                    { echo Message content rejected; exit $EX_UNAVAILABLE; }
fi

$SENDMAIL "$@" <in.$$

exit $?

It works amazingly well for adding a signature disclaimer at the bottom of every email, though the only problem is every time I try and test it say on gmail it says DKIM fails, I have gathered this is due to the body being altered after the dkim signature is done, have I got that correct, and if so is there anyway around this at all?

I would really love someones help on this, most of the guides (if not all) the ones working out ways of solving this has nothing to do with virtualmin and really not sure how to yeah how to get around this.

The reason why I know its the body being altered is that from here https://dkimvalidator.com/results when sending a test email it states:

Validating Signature

result = fail
Details: body has been altered

Thanks ever so much, Jeremy.