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

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

virtual_aliases_nostar:
  driver = redirect
  allow_defer
  allow_fail
  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
  retry_use_local_part
  domains = lsearch;/etc/localdomains
  unseen

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

2 Answers 2

headers remove to
headers add "To: $original_local_part@original_domain"
share|improve this answer

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

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.