I answered this question with my current solution, but as I said I'm not 100% happy with it. That solution to the question 'How to add a custom header to all outgoing mail' involved adding the headers_add
parameter into the existing Smarthost transport. However, I can see updates or reconfiguration reverting my edit at some point without me knowing.
I had hoped to create a minimal router which would run early on in the chain and just add the required header - this header can be added to all mail, whether it ends up being for local or remote delivery. But I couldn't find any example of a router which runs, adds the header then passes all messages on to the next router in the chain. I created this, which seems to work, but I'm very new to Exim and would be grateful if anyone can point out flaws or a better way to achieve the desired outcome. The router is /etc/exim4/conf.d/router/01_exim4-config_dev_header
:
dev_header:
debug_print = "R: dev_header for $local_part@$domain"
driver = redirect
headers_add = "X-Test-Dev-Header: true"
data = $local_part@$domain
self = pass