While Mail Forwarding with exim, how do I rewrite the To header with true destination address

Posted by Jom on Server Fault See other posts from Server Fault or by Jom
Published on 2011-03-21T22:52:35Z Indexed on 2012/04/05 23:31 UTC
Read the original article Hit count: 272

Filed under:

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.

© Server Fault or respective owner

Related posts about exim