DKIM Keeps Failing When Adding Disclaimer

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

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:

# Localize these.

# For multiple domains:
# 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; }

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

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

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

$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 when sending a test email it states:

Validating Signature

result = fail
Details: body has been altered

Thanks ever so much, Jeremy.