Process and Forward Incoming Mail with Exim
Send all incoming mail to another server with exim and process the mail normally.
Why?
If a new server is being set up to replace an old server it may be useful to allow the new server to receive the mail as it will be doing in production but still forward all email to the existing setup. Perhaps to facilitate a phased migration.
Route Email to a Pipe Transport
In the exim routing configuration look through the filters and work out
where you want to take the email and forward a copy to the other email
server. smarthost
and dnslookup
will handle external mail so to take
all local mail place the following router before system_alises
:
traffic_tap:
unseen
no_expn
no_verify
transport = msmtp_to_exchange
driver = accept
Pipes are great, msmtp
will take piped data and handle it according
to the rules setup in /etc/msmtprc
. In this example msmtp is
configured to take the email from stdin and send it to the server in
plain text on port 25:
account exchange
host 192.168.0.75
port 25
auth off
tls off
syslog on
Test that msmtp is working by sending an email (contained in the
test.eml
file in this example:
cat test.eml |msmtp --account=exchange --from=ben@fromexample.com \
ben@to.example.com
Provided the email is received on the destination server (192.168.0.75) proceed to configure the exim transport (remember order does not matter for the trasports section):
msmtp_to_exchange:
driver = pipe
command = /usr/bin/msmtp --account=exchange --from=$sender_address $local_part@$domain
message_prefix =
message_suffix =
delivery_date_add
envelope_to_add
log_output
user = exim
Now all email that is received is piped to msmtp
and will be sent
according to the msmtp configuration file in /etc/msmtprc
.
Validate Configuration
Simple way to validate the exim config:
exim -C /etc/exim/exim.conf -bV
Other Ways
Don't want to receive the email on the server? I found this on unix.stackexchange (Reference: Just forward, don't process):
begin routers
redir:
driver = manualroute
domains = *
transport = remote_smtp
route_list = * 12.34.56.78
Retry the Queue for a Specific Domain
This will also try to send emails locally if they were delayed due to a misconfiguration (not that misconfiguration is ever a problem for me personally...):
exim -Rf "mydomain.com"