Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to get Exim to work in a way that it rewrites messages that stay in the LAN differently than the ones that go out to external servers.

Just rewriting every message is possible, but that would clutter messages for local use.

Internal rewrite would be

*@*.localnet xeross-mail@server01.localnet T

And outgoing would be

*@*.localnet $1.$2@valid.domain.tld

Which would result in someuser@someserver.localnet becoming someuser.someserver@valid.domain.tld?

share|improve this question

Not much detail in this answer sorry, but it's a start and either I'll expand it, or someone else can.

You need to modify the router which normally handles all non-local mail (dnslookup), so that it also excludes mail for other hosts inside your network. You then need to add a new router to handle that mail, and direct it at a new transport. In the new transport you could add specific rewrite rules there which then only affect internal-network mails.

Something like (untested),

router (must come before the dnslookup router so that it processes local messages first) -

  driver = dnslookup
  domains = localnet
  transport = mynet_smtp

transports -

  driver = smtp
  headers_rewrite = *@*.localnet xeross-mail@server01.localnet

  driver = smtp
  headers_rewrite = *@*.localnet $1.$2@valid.domain.tld
share|improve this answer
Unfortunately T and other envelope headers can't be changed in headers_rewrite see bottom of 7. here: I've also decided to just make the sender specify a proper from instead of rewriting. Which runs just fine. Yet knowing this would still be valuable. – Not Available Aug 5 '11 at 20:46
Okay, removed the T, you could still use that rule to cover the other headers I guess, but appreciate it might not fix the full problem. – EightBitTony Aug 5 '11 at 22:45
Yeah the idea was to rewrite the outbound mails so they are accepted (As something@something.localnet isn't accepted usually). Another approach would be redirecting all outbound mail to a secondary exim instance and rewrite them on that. Luckily anything that does outbound mail modifies the from header itself, rather than having to rewrite it. – Not Available Aug 6 '11 at 13:04

Your Answer


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.