Exim append text to message body for certain attachment extensions

701 Views Asked by At

I've already disabled email delivery to our servers if certain attachment extension found. But some extension I just can't disable, because our customers are frequently using them, like .zip

How can I configure exim to just prepend some text into the message body if certain attachment extension found?

1

There are 1 best solutions below

0
Otavio Nogueira On

Can you do that using transport_filter on your smtp driver

http://www.exim.org/exim-html-3.20/doc/html/spec_14.html#SEC417

remote_smtp:
  driver = smtp
  transport_filter  = /bin/sh -c "/etc/exim/extras/footer.sh ${message_id}"

Example:

[root@web ~]# /bin/cat << EOF > /etc/exim/extras/footer.sh
#!/bin/sh

BODY=`/usr/sbin/exim -Mvb $1`

if [[ $BODY == *".zip"* ]]; then
    /usr/bin/altermime --multipart-insert --force-into-b64 --disclaimer-html=/etc/exim/extras/has-zip.html --input=/tmp/altermime.$DATE --force-for-bad-html
else
    /usr/bin/altermime --multipart-insert --force-into-b64 --disclaimer-html=/etc/exim/extras/empty.html --input=/tmp/altermime.$DATE --force-for-bad-html
fi

/bin/cat /tmp/altermime.$DATE
/bin/rm /tmp/altermime.$DATE

exit
EOF

File dependency.

[root@web ~]# /bin/cat << EOF > /etc/exim/extras/has-zip.html
This message contains .ZIP file.
EOF

File dependency.

[root@web ~]# /bin/echo "" > /etc/exim/extras/empty.html