1

I'm trying to configure exim4 to send all e-mail to my Gmail account (including e-mails to root).

It's almost working, but my Gmail address is in the BCC field of the TO field.

Here is a command I use to send a test message:

echo 'Just testing' | mail root -s 'Testing e-mail'

...and here is the result from Gmail:

Bcc: jsmith@gmail.com
Return-Path: <jsmith@gmail.com>
From: John Smith <jsmith@gmail.com>
Subject: Testing e-mail
To: <root@debian.home.myserver.net>
Date: Tue, 12 Jun 2018 11:00:55 -0400

Just testing

Here is my /etc/aliases snippet:

# /etc/aliases
root: jsmith@gmail.com

What can I be doing wrong? I'm not sure why exim4 is reading the aliases file and using that as the BCC field and not the TO field?

SofaKng
  • 389
  • 1
  • 11
  • 18

1 Answers1

2

When the mail gets forwarded to external addresses, by default only the envelope sender is rewritten. The RFC 5322, 3.6.6 doesn't require the Destination Address Fields to be unmodified, and it's not generally a totally bad idea as your purpose is legitimate. From Exim Address rewriting:

In general, rewriting addresses from your own system or domain has some legitimacy. Rewriting other addresses should be done only with great care and in special circumstances. The author of Exim believes that rewriting should be used sparingly, and mainly for “regularizing” addresses in your own domains. Although it can sometimes be used as a routing tool, this is very strongly discouraged.

Rewriting the headers may be problematic for example if you have signed the message with DKIM as the signature may not match. In this case that is if the To: header is covered by the signature i.e. listed in h= Signed header fields tag of the DKIM-Signature Header Field (RFC 6376, 3.5). Also, as the messages to root@host are usually messages related to administrating an individual server, it might actually be better to know the original destination to distinguish between the servers.

If you still want to rewrite this address, you need to add a rewrite rule for it (after begin rewrite in configuration file, sometimes in /etc/exim/conf.d/rewrite.conf). E.g.

root@host "Your Name <your.external@example.com>" t
Esa Jokinen
  • 46,944
  • 3
  • 83
  • 129
  • Thanks so much for the detailed explanation! Is it Google's SMTP server that is adding the BCC field because of the forwarding? I agree it's nice to see the original recipient but it's odd seeing a forwarded mail show as a BCC. – SofaKng Jun 12 '18 at 17:16