Maybe you developed a WordPress website years ago and today, years later, your client has started receiving emails that inform him of PHP errors. This is due to the new “site health” feature that, since WordPress version 5.2, sends an email every time a PHP error is detected.
If you want these emails not to be sent, or you want to receive them instead of the email address set as the main address in the WordPress admin, place these filters in the functions.php file of your theme or in your own plugin:
Disable WordPress PHP fatal error email sending:
I have not really seen a way to do it, but it is possible to modify the time lapse that must elapse between one email and another. So we can put an absurd figure and it is solved.
add_filter( 'recovery_mode_email_rate_limit', 'recovery_mail_infinite_rate_limit' ); function recovery_mail_infinite_rate_limit( $rate ) { return 100 * YEAR_IN_SECONDS; }
Change the recipient of the WordPress PHP fatal error email:
I think it’s the most useful. In this way you can get the mail to you instead of your client, and so the client is not scared and you are informed of the health of the site.
add_filter( 'recovery_mode_email', 'send_sumun_the_recovery_mode_email', 10, 2 ); function send_sumun_the_recovery_mode_email( $email, $url ) { $email['to'] = 'your@email.com'; return $email; }