I wanted to build a replica of our production environment on a development environment, one problem being that our production environment sends a lot of emails to our clients.
I therefore needed to redirect or restrict all of our outbound emails.
With that in mind, I needed to make sure that exim [typically what we use to send mails] would not be able to send any mail to our clients, and instead it would be sending mails to a manually defined inbox.
The first thing I needed to do, was check that exim was actually working.
I sent myself an email:
/usr/sbin/exim -v ‘alex@myemail.com’
Some message here
[CTRL+D]
That  then responded with the 250 OK codes to confirm that the mail had been delivered to myself.
That’s no good on this environment though, as I needed to ensure that exim would be redirecting to a defined mailbox. Let’s call it “some@mailbox.com”
To do this, I needed to change the routers on the exim configuration file (/etc/exim/exim.cnf).
In vim, search for the string “begin routers”
The crucial point here is that the order of which the routers are defined is important, so you will need to put the new, first rule for routers at the top of this section. What did I include?
blah:
driver = redirect
domains = whereitscomingfrom.com
data = some@mailbox.com
I then repeated the mail send:
/usr/sbin/exim -v ‘alex@myemail.com’
Some message here
[CTRL+D]
I could then see a 250 OK code, but it was actually going to some@mailbox.com instead.