No Escapes! Safe WordPress Email Testing

Test Sites with Real Data Present Real Email Problems

WordPress email testing from a cloned production site can be risky. So can testing non-email functions that may cause WordPress to send out confirmations or other types of emails.

Although many cloning utilities give you the option of starting with no data–no pages, no posts and, most importantly, no real users (except for one admin user)–there are times you need a quick test that requires data. Rather than spend time creating test data that fits the problem to be tested, you may choose to clone the entire production site, data and all. That way you can be sure your test applies the actual production situation.

The problem is, WordPress may send emails to real customers–but from the test website. I had this happen once when I deleted a real order from a test site on my local computer. I had overlooked the fact that I was using an external SMTP email service, and the plugin that provided a nice WordPress interface for this, WP Mail SMTP by WPForms, sent the email to the SMTP service even from my local machine.

Soon after, the website owner forwarded an email from that user, who believed the website may have been hacked. The email he received was clearly from a different domain name yet it also made reference to his actual order. Whoops–and how embarrassing! I apologized profusely, both to the customer and to my client.

I use Local for running websites on my own computer, and normally that software intercepts emails and saves them in its “MailHog” area for viewing and testing–but only if WordPress is using the PHP Mail function to send emails. WordPress will use PHP Mail by default. It takes extra work to set up SMTP. Many production sites do use SMTP, as mine did.

We also have a staging site on the Web so that my clients can practice using WordPress and WooCommerce features without impacting the production site. Ever since that test email incident, I have always installed and activated the Disable Emails plugin on all test sites to be sure that no emails escape the test environment. It stops SMPT emails as well as PHP Mail ones.

If No Emails Get Sent, Then How Do You Test WordPress Emails?

Now I had another problem: How could I–and my Website clients–test emails in a test environment without letting the system send any out? I needed something that would either log the emails somewhere or redirect all emails to my own email address (or that of my client when he wanted to do his own testing). My first search turned up nothing, so I asked ChatGPT about it. I was given a number of options, including:

  • Writing code.
  • Creating an SMTP server account just for the test environment using a service that allowed me to store the emails without sending them on or else to forward them only to me.
  • Using development environment software on my local computer such as Local (mentioned above, which would have been fine if I had just turned off the SMTP–but I was not about to set up local test environments on my clients’ computers!)
  • Using services such as Mailtrap or MailHog to act as fake SMTP servers.

ChatGPT’s first suggestion was actually to find an “advanced email plugin” which had capabilities beyond Disable Emails’. Since everything else sounded like more work, I tried some other keywords in a new search.

A Fantastic Solution

I was delighted to discover that there is one plugin that did exactly what I needed and more: Emails Catch All. It can log the emails, redirect all emails to my own email address, or both. And it can stop emails from going to the usual recipients.

Although Emails Catch All can itself disable email sending, I had a reason to keep the Disable Emails plugin active as well. Disable Emails has an option to save a copy of it to the WordPress “Must Use” plugins folder. That means that if you install a new copy of a cloned website over the old (without deleting all the plugins from the earlier installation), and if emails were disabled in the previous test version, they will be disabled already for the new cloned site too. That is the best insurance that emails will not be sent between the time I install a new cloned website over the old and I configure everything in the new version.

I decided to see if Emails Catch All would log emails even if the Disable Emails plugin was still active. It did, perfectly. It even had an option to show the emails in their original format, whether HTML or plain text. I am now confident that my test websites are safe from email “escapes” to production customers.

I tested both plugins together by using the settings below on Emails Catch All. You can get to the Emails Catch All settings either from the Plugins page (click “Settings” under the name of the plugin) or from the admin menu (Settings -> Emails Catch All).

  1. Under the “Settings” tab, I chose “Use more options that allows the replace or receive of emails.”
  2. Under the “Catch All Options” tab, I chose “Receive a Copy” and entered one of my seldom-used email addresses in the “Recipients” box (to be sure I did not confuse any emails being forwarded with original emails).
  3. I left “Content Type” as “HTML” and “Record Emails” as “Yes.” (Later I found there is also an “Auto” option for “Content Type,” which should show emails in whatever format they were created in.)
  4. Under the “SMTP Options” tab, I left “SMTP Auth” as “No.”

I should add the Emails Catch All is useful not only in a test environment but also in production. Obviously, you would not want to turn on the options in production to “disable all emails” or “replace all recipients,” but the options to “receive a copy” or “just record the emails” can be quite useful in either environment.

Share the Love

The Emails Catch All plugin is not well known, even though it has been around for at least seven years. When I first found it on WordPress.org, it had only six reviews–though all gave it five stars–and “400+” installations. Although (all too) many nontechnical WordPress site owners and managers may not have a test environment (the thought of which makes me shutter), I feel this plugin deserves to have many more installations, especially since its email logging and forwarding capabilities have value on production as well as test sites.

For testing emails that WordPress sends out, this plugin is nearly essential. I encourage every WordPress developer or site owner to try it out and if it works for you, leave a good review on the plugin site. And donate if you can! The plugin is free and there is no premium version. Donations will help ensure that it stays that way. Your donations therefore can help anyone on a very tight budget who needs the plugin, including small businesses just starting out who have yet to become profitable.


Need some WordPress testing and fixing? Contact me!

Leave a Comment

TOC