When you’re developing a WordPress site locally or testing in staging, you’ll generally want to prevent the site from sending out emails to customers or users.

I’ve noticed that a number of other WordPress developers are fans of MailHog (great write up by Jonathan Christopher), but in many cases it’s easier if you don’t have to install anything additional on the server.

I use two plugins to block and then log emails:

“Disable Emails” prevents the emails from sending from WordPress, and “Email Log” is able to capture their contents in case you need to view them.

Since I sync my production environment to staging and local quite frequently, I have a script in my theme that activates these plugins when it detects the new environment.

Posted by:Devin

I'm a WordPress developer based in Austin, Texas. I run a little theme shop called DevPress and work for a startup called Nano. Find me on twitter @devinsays.

2 thoughts on “ Prevent WordPress Emails in Stage or Local Environments ”

  1. Good solution. There should be reminder task to remove these plugins once local copy is upload to production server.

    If forgotten users will not get any emails and that might be bad for the client.

    1. I think it’s fine to have these on a production server, as long as they aren’t activated. I sync staging to production frequently, so it’s easier if the plugin files don’t need to be installed. The script I mentioned will activate the plugins in the right environments, but if you’re paranoid about them accidentally getting activated in production, you can write some additional code to hide them from the admin or autodisable if they ever get turned on.

Leave a Reply

Your email address will not be published. Required fields are marked *