Exim – add footer to all outgoing emails except for one user

eximfilter

I am currently managing an email server that is being handled by Exim 4.85 This server currently adds a footer to all outgoing messages. The line that adds this functionality can be found on several guides:

transport_filter=/usr/bin/altermime --input=- --disclaimer=/etc/exim_footer --disclaimer-html=/etc/exim_footer_html

However, it is now necessary to keep certain outgoing emails as they were originally. The advantage is that this has to be done for a single email address, namely bob@example.com, and all of these emails will be text-only (ie no HTML).

Example:

alice@example.com sends email ===> exim adds footer ===> delivered
  bob@example.com sends email =========================> delivered

I figured I could make use of the string expansion capabilities and make altermime use a blank file for that but it has been a nightmare so far. I have basically been getting

Expansion of [...] failed: condition name expected, but found ""

and

transport filter process failed (127): unable to execute command

What bothers me, is that testing the expansion via the exim -bem command returns the desired output.

These are just a few of my failed attempts:

transport_filter=/usr/bin/altermime --input=- --disclaimer='${if eq {$sender_address}{bob@example.com}{/etc/exim_footer}{/etc/empty_file}}'
transport_filter=/usr/bin/altermime --input=- --disclaimer=${if eq {$sender_address}{bob@example.com}{/etc/empty_file}{/etc/exim_footer}} --disclaimer-html=/etc/exim_footer_html
transport_filter={${if eq {$sender_address}{bob@example.com}{/etc/empty_file}{/usr/bin/altermime --input=- --disclaimer=/etc/exim_footer --disclaimer-html=/etc/exim_footer_html}}}

Any ideas on how to do this?

Best Answer

Set your transport_filter to bash/python/.. script

transport_filter = /scripts/exim_add_signature.sh $sender_address

See http://www.exim.org/exim-html-current/doc/html/spec_html/ch-generic_options_for_transports.html for documentation about transport_filter.

In the script do the following (pseudo-code):

no_signature_mails = ["bob@example.com"]
if (argv[1] isnotin no_signature_mails)
    /usr/bin/altermime --input=- --disclaimer=/etc/exim_footer --disclaimer-html=/etc/exim_footer_html
Related Topic