Dear Maintainer,
Even when dc_hide_mailname is set, mails sent to remote hosts leak the local
intranet hostname. This is because of two reasons, which the below patch fixes.
1. Reason #1 is the Received: header added by exim4 as it receives the request
from the local MUA via /usr/sbin/sendmail. This patch simply removes this
header for mails sent outwards via the smarthost. (It preserves the header for
locally-sent mails, or for mails sent outwards when exim4 is configured as an
internet facing "regular" SMTP server.)
This matches the behaviour of ordinary SMTP clients that send directly to an
SMTP server without adding a Received: header, which is what "smarthost" is
supposed to emulate as I understand. For this reason, this patch does the
rewriting unconditionally, but it's easy to guard it via "ifdef HIDE_MAILNAME"
if that is preferred.
2. Reason #2 is the Message-ID. This patch rewrites the Message-ID domain name
to the configured DCreadhost, like how other headers are already rewritten.
exim4 doesn't support rewriting Message-ID in headers_rewrite, so we do it
using headers_add and headers_remove instead.
This rewriting is only in effect if HIDE_MAILNAME is on.
Patch:
~~~~
--- exim4.conf.template.orig 2023-06-25 21:26:18.964387306 +0100
+++ exim4.conf.template 2023-06-26 02:29:48.362735601 +0100
@@ -1733,6 +1742,12 @@
.ifdef REMOTE_SMTP_SMARTHOST_TLS_VERIFY_HOSTS
tls_verify_hosts = REMOTE_SMTP_SMARTHOST_TLS_VERIFY_HOSTS
.endif
+ # Don't add Received header when acting as a smarthost, to mimic regular SMTP clients
+ headers_remove = Received
+.ifdef HIDE_MAILNAME
+ headers_remove = Message-Id
+ headers_add = Message-Id: <${local_part:$h_message-id:}@DCreadhost>
+.endif
.ifdef REMOTE_SMTP_HEADERS_REWRITE
headers_rewrite = REMOTE_SMTP_HEADERS_REWRITE
.endif
~~~~
It will need to be duplicated for the split-config, of course.