We have a working exim setup at a site, where users can send and receive mails. We are trying to setup a server to send some warnings and errors using email to an address that is outside the local network.
The problem is:
The program that sends the mails sends them using the username it runs under and the local hostname of the server. This cause the mails to have a sender of format: [email protected]. Exim sends these mails to the ISP's SMTP server, which rejects the mails as they have an illegal or unverifiable sender (the internal address).
I'm thinking I should configure exim to rewrite the sender when:
- sender's domain is on the local network
- receiver's domain is outside the local network
I tried setting some kind of rewriting in the exim config, but did not manage to get it to work. I'd show what I have tried, but I ran out of time on the last visit to the site, and had to revert to the original version losing all the changes I tried.
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:On your MX server add an alias like:
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 therewrite
section of the configuration file.The flags have the following meanings:
Read Chapter 31 of the Exim Specification for more detail on message rewriting
/etc/email-addresses
is handy when you only need to associate one email address per username. However if your user needs to send emails with multiple addresses, you will have to modify/etc/email-addresses
each time, and you will inevitably end up using the wrong address.Another approach is to send the email using the
exim4
command and its-f
option :Note that for the
-f
option to work, you need either your user to be in exim's trusted users or exim to accept him as an allowed untrusted sender.In my case the latter was default, thanks to this wildcard in
/etc/exim4/conf.d/main/02_exim4-config_options
:The other solution is to add the following line in
/etc/exim4/conf.d/main/00_local_settings
(assuming exim's split configuration, and create it if it doesn't exist already) :Both options need a reload of exim's configuration. Under Debian :