How do you disable sending email messages to WordPress – Disable wp_mail() function

Providing a valid email address is a mandatory step in installing WordPress. On the email address of the admin user wine Password reset messages, Site health And messages then When visitors leave comments. For many reasons, however, you want to know how to turn off email messages in WordPress. The main reason being the spam messages or even worse the vulnerability of a plugin that exploits the function wp_mail() and sends spam messages to tens of thousands of addresses.

Most WordPress spam messages are sent through PHPMailer when one form is vulnerable or when a plugin allows third -scripts PHP to use wp_mail().

If you have a blog or site on WordPress and it is not necessary for the system to send email messages to administrator or users, then the best solution is to disable the WordPress email function.

How do you disable sending email in WordPress - Disable WP_Mail () Function
How do you disable sending email messages to WordPress

Before following the steps in the tutorial below, keep in mind that this method will completely deactivate the WordPress email system. No email messages will be sent to reset password, messages when the site encounters functionality problems or when users comment on the blog. If you use modules like contact form, set them to not send email messages via PHPMailer.

How do you disable sending email messages to WordPress

This method does not require the installation of a plugin. All you have to do is edit the functions.php file of the active basis on the blog and add the following code lines:

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

Save the change. That's all.

Passionate about technology, I write with pleasure on stealthsetts.com starting with 2006. I have a rich experience in operating systems: Macos, Windows and Linux, but also in programming languages ​​and blogging platforms (WordPress) and for online stores (WooCommerce, Magento, Presashop).

Home Your source of IT tutorials, useful tips and news. How do you disable sending email messages to WordPress – Disable wp_mail() function
Leave a Comment