-
Notifications
You must be signed in to change notification settings - Fork 178
Q0803
I want to rewrite local addresses in mail that goes to the outside world, but not for messages that remain within the local intranet.
You can use the headers_rewrite
option on a transport to do this. The
rewriting will then apply to just those copies of a message that pass
through the transport. The return_path
option can similarly be used to
rewrite the sender address. There is no way of rewriting recipient
addresses at transport time. However, as these are by definition remote
addresses, you probably don't want to rewrite them. You have to set up
the configuration so that it uses different SMTP transports for internal
and external mail. If you are using a single router in both cases, you
could configure it like this:
dnslookup:
driver = dnslookup
transport = ${if match{$domain}{\N\.my\.domain$\N}{int_smtp}{ext_smtp}}
This example uses the int_smtp transport for domains ending in .my.domain, and ext_smtp for everything else. The ext_smtp transport could be something like this:
ext_smtp:
driver = smtp
headers_rewrite = *@*.my.domain \
${lookup{$1}cdb{/etc/$2/mail.handles.cdb}{$value}fail}
return_path = \
${if match{$return_path}{\N^([^@]+)@(.*)\.my\.domain$\N}\
{\
${lookup{$1}cdb{/etc/$2/mail.handles.cdb}{$value}fail}\
}\
fail}
This example uses a separate file of local-to-external address
translations for each domain. This is not the only possibility, of
course. The headers_rewrite
and return_path
options apply the same
rewriting to the header lines and the envelope sender address,
respectively.
- How can I get Exim to strip the hostname from the sender's address?
- I have Exim configured to remove the hostname portion of the domain on
- I want to rewrite local addresses in mail that goes to the outside
- I'm using this rewriting rule to change login names into friendly names, but if mail comes in for an upper case login name, it doesn't get rewritten.
- Is it possible to completely fail a message if the rewrite rules fail?
- I'm using $domain as the key for a lookup in a rewriting rule, but
- I want to rewrite local sender addresses depending on the domain of the
- I want to rewrite recipient address depending on the domain of the