4

Since WordPress 5.2 there is an automated E-Mail on PHP exceptions. In some smaller projects I just upload the files for new extensions while developing - whenever an error occurs then, the site admin is getting an email. This is usually one of my freelance customers and they unecessarily panic then.

Therefore I would like to turn of this email notifications (without changing the admin email). Is there some kind of action/filter, config option (e.g. define) to disable this behaviour? Some true/false option would be the best? Then I can disable this just for the times I develop.

3
  • Do you only want to disable the email notification? If not, setting WP_DISABLE_FATAL_ERROR_HANDLER should deactivate the whole thing
    – kero
    Commented Jul 5, 2019 at 15:56
  • @kero It would be better to only disable the email notification. I do not know exactly what the error handler does, therefore I am not sure if it is a good idea to disable it completely.
    – Blackbam
    Commented Jul 5, 2019 at 16:01
  • Well with define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', true ); define('WP_DISABLE_FATAL_ERROR_HANDLER',true); you can still see and log the errors, but not mail them
    – Fanky
    Commented Aug 8, 2021 at 13:58

2 Answers 2

6

There was some discussion on it a few weeks ago you can find here: https://make.wordpress.org/core/2019/04/16/fatal-error-recovery-mode-in-5-2/

According to that and looking through the core, you can accomplish that with one of two methods:

define('RECOVERY_MODE_EMAIL', '[email protected]');

OR

add_filter( 'recovery_mode_email', 'recovery_email_update', 10, 2 );
  function recovery_email_update( $email, $url ) {
    $email['to'] = '[email protected]';
    return $email;
 }

Hope that helps!!

1
  • 1
    Is the aim of this to change the email? How is it connected with disabling? Do you mean to set it to a non-existent email?
    – Fanky
    Commented Aug 8, 2021 at 14:00
7

I have thoroughly tested the above suggestions and neither of them work.

The only thing I have found that DOES work is adding the following to "wp-config.php":

define('WP_DISABLE_FATAL_ERROR_HANDLER',true);

4
  • Worked perfectly
    – Gavin
    Commented Oct 1, 2020 at 15:23
  • What does this do besides disabling the e-mail? Commented Nov 3, 2021 at 9:11
  • 1
    @JānisElmeris As most of the defines in Wordpress it seems do only this one thing: The only place where it gets checked is in wp_is_fatal_error_handler_enabled. see developer.wordpress.org/reference/functions/… Commented Feb 10, 2022 at 11:00
  • OK, thanks! You wouldn't tell by the name though. It may potentially do something else in the future, as it's a "fatal error handler", but I would like to disable the e-mailing only. Commented Feb 10, 2022 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.