Skip to content

Instantly share code, notes, and snippets.

@RupW
Created March 15, 2021 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RupW/7ef75c22e88dff18e632eb6676635bd0 to your computer and use it in GitHub Desktop.
Save RupW/7ef75c22e88dff18e632eb6676635bd0 to your computer and use it in GitHub Desktop.
Two example implementations for wp_mail_failed
// Echo out wp_mail() errors to the current page
// from https://developer.wordpress.org/reference/hooks/wp_mail_failed/
function echo_wp_mail_failed( $wp_error ) {
echo "<pre>";
print_r($wp_error);
echo "</pre>";
}
add_action( 'wp_mail_failed', 'echo_wp_mail_failed', 10, 1 );
// Write wp_mail() errors to the debug log
function log_wp_mail_failed( $wp_error ) {
error_log('wp_mail_failed: ' . print_r( $wp_error, true ));
}
add_action( 'wp_mail_failed', 'log_wp_mail_failed', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment