Skip to main content

exim rewrite subject for email coming from External domain

for incoming email not from our domain (external domains) we want to add [EXTERNAL] to the subject but if it already contains [EXTERNAL] we do not want to add it again.

I made the changes on our Sophos UTM 9 system.  More than likely it will require rewriting these files after a update.  This should apply to other systems running exim.

If your exim is installed in chroot enviroment you want to place the files there
on Sophos UTM this is /var/chroot-smtp/etc/
on system with non chroot it may be /etc/exim/

created a file /var/chroot-smtp/etc/exim.system_filter
with following contents
change domains to match your enviroment.  The > placed on the end of the match sstring so it does not match email address spoofing in display name using your domain.

 /var/chroot-smtp/etc/exim.system_filter
if
$header_from: does not contain "@yourdomain.com>"
and $header_from: does not contain "@yourdomain.localdomain>"
and $header_from: does not contain "@additionaldomain.com>"
and $header_subject: does not contain "[EXTERNAL]"
then
headers add "Old-Subject: $h_subject:"
headers remove "Subject"
headers add "Subject: [EXTERNAL] $h_old-subject"
headers remove "Old-Subject"
endif

add to exim.conf
for Sophos UTM 9 this file is located in  /var/chroot-smtp/etc/exim.
system_filter = /etc/exim.system_filter

In sophos we are running exim in chroot under /var/chroot-smtp the exim.conf does not need that portion in the path since its jailed.

This file has worked for my environment , I hope this is helpful to you

Sam Saqr

Comments