You can headers_add in a router, but I can see no way to change the SMTP From aka Envelope-From within a router or indeed anywhere using the same conditions the router triggers on.

I need to emulate mailman behaviour for a very small number of exim "alias" type list expansions.

Eg: if someone sends email to my: [email protected] address and that is handled by the redirect router section, only then do I want to rewrite the SMTP From to be something local, possibly [email protected]

Similar to how mailman would handle it. The main reason: SPF at the next level mail gateway and mail sent from external users.

I've tried conditional rewrite rules but to be honest, I've never done those before and I'm getting in a muddle.

Many thanks,


2 Answers 2


if you want to rewrite the envelope sender in a router use the "errors_to" action in that router

errors_to = [email protected]

http://www.exim.org/exim-html-current/doc/html/spec_html/ch-generic_options_for_routers.html says in part:

If an address for which errors_to has been set ends up being delivered over SMTP, the envelope sender for that delivery is the errors_to value, so that any bounces that are generated by other MTAs on the delivery route are also sent there.


May be the most straightforward way is to use the piping to the script/binary that will perform an arbitrary transformations:

begin routers
  driver    = accept
  transport = myscript
  condition = ## every distinction you need ##  

And the transport:

begin transports
  driver  = pipe
  command = /path/to/script 

The whole message including the headers, the empty line and the body will be passed to the stdin of the script/binary. The script should read the stdin and after proceeding should run the sendmail -t command to resubmit the transformed message locally. The easiest script I've think of is the next:


cat /dev/stdin \
| sed '1 s/[email protected]/[email protected]/' \
| sendmail -t


exim will receive the modified message and proceed it as usual. You have to ensure that no routing loops created and no message passed to the script and back again and again.

Also you have to ensure the exim user have enough permissions to run the script and, especially the wrapped sendmail -t command. May be you have to setup the sudo rules properly.

  • Thanks - that's an idea (I do have some pipe scripts in perl that already handle special case mail processing into a database, so this is not alien to me - though I was so focussed on looking to exim that I didn't think of this... I also have an active systemfilter so I may be able to pull the same trick there (will have to check the docs) - Cheers and thank you, Tim
    – Tim Watts
    Mar 21, 2019 at 14:51
  • @TimWatts Bundled exim's address rewrite is a bit rudimentary but I think that's made intentionally cause the piping to the external tools of the arbitrary complexity is quite simple. Once I've made the mailbot driven by special messages that allows me to do some basic operations including system reboot.
    – Kondybas
    Mar 21, 2019 at 16:47
  • this does not address envelope sender.
    – Jasen
    Sep 17, 2019 at 9:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .