Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

I have mail forwarding setup with exim using a domain forwarding file.

  driver = redirect
  data = ${if exists{/etc/valiases/$domain}{${lookup{$local_part@$domain}lsearch{/etc/valiases/$domain}}}}
  file_transport = address_file
  group = mail
  pipe_transport = virtual_address_pipe
  domains = lsearch;/etc/localdomains

It is working fine.

However, I would like to rewrite the "to" header. In my system filter, I would like to put something like:

  headers remove to
  headers add "To: $recipient:"

I've tried:

  headers remove to
  headers add "To: $recipient:"

  headers remove to
  headers add "To: $h_env-to:"

  headers remove to
  headers add "To: $env-to:"

The intent is to have the end recipient see their own email address in the To: line of their mail client.

I can't seem to figure out what the correct header is for the final destination of the email so that I can put it in the to header. I've read through the Exim docs and can't seem to find it. I've also looked in the headers in an email at a mail client and can't see it there either.

Any suggestions would be appreciated.

share|improve this question

You want to replace the existing To: header (which may contain other recipients or the name of a mailing list) with the computed final destination of the email? You already have some code to figure out where the email has to end up, so use that:

headers remove to
headers add "To: ${if exists{/etc/valiases/$domain}{${lookup{$local_part@$domain}lsearch{/etc/valiases/$domain}}}}"
share|improve this answer
headers remove to
headers add "To: $original_local_part@original_domain"
share|improve this answer

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.