How to disable the sending of email messages in WordPress - Disable wp_mail() function

Providing a valid email address is a mandatory step in the installation WordPress. On the user's email address admin wine password reset messages, site health and messages then when visitors leave comments. For many reasons, however, you want to know how to disable the sending of email messages in WordPress. The main reason being 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 spam messages from WordPress are sent via PHPMailer when a form is vulnerable or when a plugin allows third-party PHP scripts to use wp_mail().

If you have a blog or a website 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 email function a WordPress.

How to disable the sending of email messages in WordPress - Disable wp_mail() function
How to disable the sending of email messages in WordPress

Before following the steps in the tutorial below, remember that this method will completely disable your email system WordPress. Email messages will no longer be sent to reset the password, messages when the site encounters functionality problems or when users comment on the blog. If you use modules like Contact Form, set them not to send email messages via PHPMailer.

How to disable the sending of email messages in 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 blog theme and add the following lines of code:

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

Save the change. That's all.

how to » WordPress » How to disable the sending of email messages in WordPress - Disable wp_mail() function

Passionate about technology, I like to test and write tutorials about operating systems macOS, Linux, Windows, about WordPress, WooCommerce and configure LEMP web servers (Linux, NGINX, MySQL and PHP). I write on StealthSettings.com since 2006, and a few years later I started writing on iHowTo.Tips tutorials and news about devices in the ecosystem Apple: iPhone, iPad, Apple Watch, HomePod, iMac, MacBook, AirPods and accessories.

Leave a Comment