Exim: Change sender address when sending mails out of local network
The file /etc/email-addresses
should handle the problem. This is a standard part of the Exim distribution. You will need to configure one record for each local user sending email.
Try a line to /etc/email-addresses
like:
myapp: [email protected]
On your MX server add an alias like:
donotreply: :blackhole:
Use a Reply-to:
header to allow the recipient to reply to the message.
The file /etc/email-addresses
is used the following rewrite code, which should be at the start of the rewrite
section of the configuration file.
*@+local_domains "${lookup{${local_part}}lsearch{/etc/email-addresses}\
{$value}fail}" Ffrs
begin rewrite
[email protected] [email protected] SFfrs
The flags have the following meanings:
- S - Do all rewriting at SMTP time. This means that all of the following flags are done immediately as the data they apply to is coming in, not delayed until later.
- F - Rewrite the envelope from field.
- f - Rewrite the From: header field.
- r - Rewrite the Reply-To: header field.
- s - Rewrite the Sender-To: header field.
Read Chapter 31 of the Exim Specification for more detail on message rewriting