Block sending emails on dev version

I do have about 20 of forms, all of them with multiple separate notifications - to admin(me), to their recipients, to marketing dept. etc. I also have 2 web enviroments - separate WP’s - dev version and prod version - when i make a new feature, I make it on the dev and then I copy DB & files to prod.
Of course on dev version i do not want emails to be send to anyone except me. And on production version i do not want emails to be send to me.
Have anyone created such function, that would check the enviroment (some variable or hostname) and depending on it block some of the notifications?

The way I normally handle this is to block all emails on the dev site, and funnel them into email logs instead. I wrote a plugin to block WP emails:

Add an email logger as well, and you’re set, e.g.

NB: it won’t stop other feeds like Mailchimp signups etc. Your best bet there is to deactivate the feeds.

1 Like

Thank you, interesting approach. My needs would solve combination of your diable emails, emails log and a action, that would automaticaly turn them on on dev domain. If no other simpler solutions come up, i will look into it. Thx

1 Like

Ooh! Ooh! I just remembered something I saw on Twitter recently, might be just the ticket for your needs:


If you’re only looking to control emails sent by Gravity Forms, you should be able to adjust this snippet to check your environment and conditionally intercept email notifications.

1 Like