Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have a working exim setup at a site, where users can send and receive mails. We are trying to setup a server to send some warnings and errors using email to an address that is outside the local network.

The problem is:

The program that sends the mails sends them using the username it runs under and the local hostname of the server. This cause the mails to have a sender of format: myapp@myserver.mydomain. Exim sends these mails to the ISP's SMTP server, which rejects the mails as they have an illegal or unverifiable sender (the internal address).

I'm thinking I should configure exim to rewrite the sender when:

  • sender's domain is on the local network
  • receiver's domain is outside the local network

I tried setting some kind of rewriting in the exim config, but did not manage to get it to work. I'd show what I have tried, but I ran out of time on the last visit to the site, and had to revert to the original version losing all the changes I tried.

share|improve this question
up vote 4 down vote accepted
begin rewrite
myapp@myserver.mydomain   legal.user@myserver.mydomain   SFfrs

The flags have the following meanings:

  1. S - Do all rewriting at SMTP time. This means that all of the following flags are done immediately as the data they apply to is coming in, not delayed until later.
  2. F - Rewrite the envelope from field.
  3. f - Rewrite the From: header field.
  4. r - Rewrite the Reply-To: header field.
  5. s - Rewrite the Sender-To: header field.

Read Chapter 31 of the Exim Specification for more detail on message rewriting

share|improve this answer
This is how I got it to work, except: There has to be a ^ in the beginning of the rule, as S excepts a regexp – Esa Varemo Oct 26 '13 at 19:38
s should be "Sender:" header not "Sender-To:" (And it is a too tiny change to edit the post) – Gert van den Berg Feb 17 at 9:37

The file /etc/email-addresses should handle the problem. This is a standard part of the Exim distribution. You will need to configure one record for each local user sending email.

Try a line to /etc/email-addresses like:


On your MX server add an alias like:

 donotreply:    :blackhole:

Use a Reply-to: header to allow the recipient to reply to the message.

The file /etc/email-addresses is used the following rewrite code, which should be at the start of the rewrite section of the configuration file.

*@+local_domains "${lookup{${local_part}}lsearch{/etc/email-addresses}\
                  {$value}fail}" Ffrs
share|improve this answer
/etc/email-addresses does not exist on my server. Can I just create it, or does that indicate that something is missing? – Esa Varemo Oct 26 '13 at 17:51
@EsaVaremo Grep your configuration file for email-addresses, or check your configuration file for the rewrite section. It is possible this was not configured in your distribution. – BillThor Oct 26 '13 at 17:57
I tried grep, locate and looked for a few man-pages, but did not find anything. Should the file be defined in exim.conf? – Esa Varemo Oct 26 '13 at 18:24
@EsaVaremo The line at the end of my response should be in the rewrite section of exim.conf. If it is missing add it. Make sure the variable local_domains includes your domain. – BillThor Oct 26 '13 at 23:31
I noticed your edit a while after I had made my last comment. For whatever reason I did not get that to work though, so I went with the other answer, as I was running out of time. I do not doubt that this is right, I propably just had mistyped/configured something... – Esa Varemo Oct 27 '13 at 9:30

Your Answer


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.