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.


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}}}}"
headers remove to
headers add "To: $original_local_part@original_domain"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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