DEV Community

Cover image for Disabling All Emails in WordPress
trueqap
trueqap

Posted on

Disabling All Emails in WordPress

It's a common scenario: you're developing a site that's been cloned from a live site, filled with operational features, notifications, plugins, and automated email sending. For instance, in the case of an e-commerce site, it's not ideal if the development version is bombarding users with emails. In such cases, it's always necessary to disable the email sending function.

Of course, there are plugins designed for this purpose, but I'm a fan of simplicity. I have a less elegant, but perfectly functional solution.

I simply override the wp_mail function.

If you find yourself in a similar situation and want to disable all emails, then paste the following line into your wp-config.php file (at the very end):

With this solution, you eliminate the risk that comes with using a plugin to turn off email notifications. There's always a chance that, while you're in the process of setting up the plugin, a notification email might slip through and reach your users. By overriding the wp_mail function directly in the wp-config.php file, you ensure that no emails are sent out from the moment you implement this change.

Top comments (0)