Testing Server, Don't accidentally send your customers an email!

Does your company have a testing, development, or staging machine where you test your software before deploying on live? Have you ever accidentally sent a customer or client an email from one of those machines? Read on, and we’ll tell you how to prevent that.
If your company uses testing, development, or staging servers to test software on before deploying into a live environment, you may have accidentally sent customers an email from one of those systems. Ideally, we would *never* want to send a customer or client an email from a non production environment. They are confusing, can cause a customer to get mad (I didn’t place that order!), etc. It could actually be a PO to a supplier, which would also be bad. If you are using postfix, then it easy to fix.

What we will be doing here is this… We will whitelist our private domains we do want to allow emails to go to, and, discard everything else. This means, by design, that we must be using our own domains or company domain for the whitelisted domains. After all, a developer who wants email but is using gmail for example, we certainly don’t want to whitelist them as many customers would also use that. So, the caveat is we have to use domains only we use. If you can live with that, then, it’s really simple.

Edit /etc/postfix/main.cf and add a line as follows: transport_maps = hash:/etc/postfix/transport

Then, edit or create /etc/postfix/transport and add lines as follows:

whitelisteddoamin1.com :
whitelisteddomain2.com :
* discard:

This tells postfix, in order, to send as normal all emails to anyone in whitelisteddoamin1.com and whitelisteddoamin2.com as normal, nothing changes from however it sends now. It ends with discarding anything else.

After changing the above, be sure and postmap transport file, and, postfix reload and you are all set. I would suggest testing it to be sure.

Now, you will never again send an embarrassing email outside of the developers or testers you want to send emails to.
blog comments powered by Disqus

© 2017 by 5 Diamond IT Consulting, Contact Us
Privacy Policy | Site Map

Open source software we work with includes Apache HTTP server, cURL, Fedex Shipping for osCommerce and Zen Cart, MySQL, Mariadb, osCommerce shopping cart, PHP, and Zen Cart shopping cart. We offer services such as shell scripting, HP3000 consulting. Tools we recommend for small business include KALL8 toll free phone service, VOIPo VOIP phone service