One way to safely isolate your test environment is to configure a mailserver that catches all mails from and to all domains, and puts them in one big inbox. If I configure that mailserver in my test environment, all mails are cought.
Many mailservers support this scenario. I used an open source one, hmailserver on an Azure VM. Installation steps:
- Create an Azure VM. I used a standard DS1 v2, but a lighter version probably also suffices. I chose Windows Server 2016. Again, many others also work.
- Give your machine a DNS name. e.g. anymail.yourregion.cloudapp.azure.com
- In the portal, open ports 25, 143 and 578 for TCP
- Connect through remote destop
- On the machine itself, also open ports 25, 143 and 587 in firewall settings
- Enable .net 3.5. I did this through Programs and Features => Turn Windows Features on and off.
- Download hmailserver to your VM D: drive (this is temporary space). You need to add the hmailserver.com-domain to your trusted sites to download it.
Install it using default settings. Then configure it:
Create a domain anymail
- On the domain tab advanced configure the cathchall-address: anymail@anymail
- Create an account in your domain: anymail@anymail and choose an easy password.
- Create a rule: delete all mail from
mailer-daemon@anymail.yourregion.cloudapp.azure.com
- In settings - SMTP enter anymail.yourregion.cloudapp.azure.com as local hostname. Set number of retries and minutes between each retry to 0. Set the remote host name to localhost port 25 (so you really cannot mail out)
- In anti-spam whitelist 0.0.0.0 through 255.255.255.255
- In advanced - mirror enter anymail@anymail
- In advanced - IP ranges delete localhost
- In advanced - IP ranges double click internet and remove all checkboxes before 'requere SMTP authentication"
- IN advanced - Autoban disable autoban.
Everything should work now. You should be able to configure anymail.yourregion.cloudapp.azure.com in your configuration, but also in your mail program (e.g. outlook). You can check that you can send mails from any sender to any recepient. Test that mails to your regular e-mail address don't arrive in your regular mailbox.
DIAGNOSTICS
While tweaking settings I often looked at status -> delivery queue. This queue is not automatically refreshed, so you need to refresh it manually.
You may need to clear it while testing. (I often got into loops, resulting in many many messages.)