How to Stop WordPress From Sending Emails

empty-mailbox

WordPress doesn’t send out too many emails. They’re usually only generated for an important notice, or when an action is required on your part. However, there are a few different circumstances under which you may not want WordPress to send any emails.

For example, when working on a development site, or even a production site, you may inadvertently trigger emails that send to real users when testing or making changes.

The best developers are able to stay invisible. Ideally, you don’t want any users to know or suspect that you are working on the site, so it’s important to suppress emails that might be triggered by your work. Fortunately, there are two plugins that will do this for you automatically.

Stop Emails

The Stop Emails plugin, created by Sal Ferrarello, works silently to prevent any outgoing emails from being sent using wp_mail() function. WordPress will continue to act normally, as if the emails were sent successfully.

When the plugin is active, you’ll see a notice in the admin area to remind you that emails are not currently being sent.

no-emails-notice

Stop Emails also has a filter that you can use, which will allow you to log emails and send the information to the php_error.log:

[php]add_filter(‘fe_stop_emails_log_email’, ‘__return_true’);[/php]

Disable Emails

Disable Emails is a similar plugin, created by WordPress plugin developer Ross McKay. It stops any and all emails, using the standard wp_mail() function by replacing it with an empty function. Disable Emails is different in that it is totally silent and does not show an admin notice to remind you that emails are stopped.

It also has a more explanatory readme.txt file that cites several scenarios wherein you might consider shutting WordPress emails off:

  • Demonstration websites that allow users to do things that normally send emails
  • Development / test websites with live data that might email real customers
  • Bulk-loading data into websites which might trigger emails
  • Adding new sites into multisite installations

Both of these plugins are aimed at developers who probably want to turn emails off temporarily or only on a development site. You could also use the plugin to create a totally silent WordPress site that never sends out any notifications, although this is probably not recommended.

Email notifications are still one of the easiest ways to keep your finger on the pulse of your website when you don’t visit every day. If you opt to use one of these plugins temporarily on a live site, it’s important to remember to turn the plugin off when you’re finished working.

8

8 responses to “How to Stop WordPress From Sending Emails”

  1. These plugins are great as long as you’re sure that everything you’re using is sending mail through wp_mail. Not all developers are equally strong on doing things the WordPress way.

    A piece of advice? Before you start working on a dev server that has user accounts on it, change all of your users email via MySQL using something like:

    update wp_users set user_email = CONCAT(“sam+”, ID, “@getparka.com”);

    That way, even if everything gets screwed up, your dev site CANT email your users because it doesn’t know who they are.

    • Great point samhotchkiss. I’m the author of the Stop Emails plugin and this is definitely a limitation. I hadn’t thought about changing the users’ email addresses. I like this idea but would like to be able to revert back to the original addresses. I wonder if a filter to modify the email address could create the same behavior you’ve outlined above.

      • Hey Sal– what if you just stored the users “real” emails in the user meta? So you iterate through, swap out their real emails for the fakes, add the real emails as user meta, then when the user wants to “restore” their emails, you go back through and reverse the process?

        • I like this idea, samhotchkiss. I think to put it in place, it would make sense to do an Ajax call to iterate through the users to avoid a problem with timing out. However, for me personally I’m not sure it is worth the additional complexity as the plugin is solving the problem I had. Of course, if someone else wants to write that code I’m always happy to accept a pull request on the GitHub repo https://github.com/salcode/stop-emails or use another plugin if someone builds a better one.

          I did look for a filter that would allow me to programmatically modify the email address when it loads but I didn’t spot a good place to hook in to get this behavior. To me this would have been an ideal behavior, “changing” the email addresses without iterating through all the users.

          Thanks for all the thought provoking comments.

Newsletter

Subscribe Via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.