We use Exim on our servers to send emails only from local automated users, as root, cron, etc.
We have to specify every possible users into /etc/email-addresses
. For example:
root: [email protected]
cron: [email protected]
backup: [email protected]`
This allow us to receive every email generated.
The problem is when we add a user for whatever reason (for example when we add a package, some add a user), we can forget to add this user to /etc/email-addresses
. Most of the time it's not a problem, but this is not clean. And the overall method is not clean.
We'd like to configure Exim to send every emails with the same source address. i.e. every sent email comes from [email protected]
One way could be to use a wildcard or a regular expression into /etc/email-addresses
but this is not supported.
I don't currently understand Exim enought to figure out how to modify this in a way or another.
Ideally, Exim should look into /etc/email-addresses
first, and if no match it use the predefined address. But this is very secondary.
There are two places where this address is used:
1. when Exim send the FROM:
command to the smtp server
2. inside the header
edit:
The rewrite section is the original one from Debian
begin rewrite
.ifndef NO_EAA_REWRITE_REWRITE
*@+local_domains "${lookup{${local_part}}lsearch{/etc/email-addresses} \
{$value}fail}" Ffrs
*@ETC_MAILNAME "${lookup{${local_part}}lsearch{/etc/email-addresses} \
{$value}fail}" Ffrs
.endif
A much better approach:
Modify the rewrite section: change
lsearch
bywildlsearch
(two lines have to be changed). This allow to use wildcards and regular expression into/etc/email-addresses
So the
/etc/email-addresses
can contain this kind of thing:root: [email protected]
*: [email protected]
The file is processed from top to bottom. So if an email is sent to root, it is really sent to [email protected]. And every other emails are sent to [email protected]
Somewhere after
begin rewrite
(and before the next section starting with a begin) add this:* [email protected] Ffrs
The wildcard stand for every addresses
[email protected] is the address you want
Ffrs stand for:
F rewrite the envelope From field
f rewrite the From: header
r rewrite the Reply-To: header
s rewrite the Sender: header
This will replace EVERY sender address.