Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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: alert@example.com  
cron: alert@example.com  
backup: alert@example.com` 

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 alert@example.com

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
share|improve this question
    
Could you include in an edit the REWRITE CONFIGURATION section of your exim.conf? –  brent Apr 9 '12 at 15:06

2 Answers 2

Somewhere after begin rewrite (and before the next section starting with a begin) add this:
* name@domain.tld Ffrs

The wildcard stand for every addresses
name@domain.tld 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.

share|improve this answer
up vote 1 down vote accepted

A much better approach:

Modify the rewrite section: change lsearch by wildlsearch (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: root@example.com
*: alert@example.com

The file is processed from top to bottom. So if an email is sent to root, it is really sent to root@example.com. And every other emails are sent to alert@example.com

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.