How to disable wp_mail() & prevent WordPress from sending emails – without plugin

A simple way to prevent WordPress from sending emails without the need of a plugin.

Prevent WordPress from sending emails

Sometimes you might want to prevent WordPress from sending emails. This can be handy when working on a staging environment and want to make sure no emails are sent from the site.

To stop WordPress from sending emails altogether, simply add this to your theme’s functions.php file:

add_filter('pre_wp_mail', 'templ_disable_emails');
function templ_disable_emails() {
    return false;
}

Leave a Reply

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