Prevent WordPress Emails in Stage or Local Environments

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.

About Devin

I am a developer based in Austin, Texas. I run a little theme shop called DevPress and help manage a WooCommerce shop with Universal Yums. Find me on twitter @devinsays.

2 Responses

  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.

Leave a Reply to Richard Cancel reply