Created
July 18, 2022 09:06
-
-
Save alanef/3811307aba105ebe873ce3ba91eac066 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| * add any mail errors and error messages to DEBUG log | |
| */ | |
| add_action( 'wp_mail_failed', function ( $wp_error ) { | |
| /** @var $wp_error \WP_Error */ | |
| if ( defined( 'WP_DEBUG' ) && true == WP_DEBUG && is_wp_error( $wp_error ) ) { | |
| error_log( 'Email - wp_mail error msg : ' . $wp_error->get_error_message() ); | |
| $a=$wp_error->get_error_codes(); | |
| foreach ( $wp_error->get_error_codes() as $error_code ) { | |
| $b=$wp_error->get_all_error_data( $error_code ); | |
| error_log( print_r( $wp_error->get_all_error_data( $error_code ), true ) ); | |
| } | |
| } | |
| }, | |
| 10, | |
| 1 | |
| ); | |
| /* | |
| * Log all out going emails before sending | |
| */ | |
| add_action( | |
| 'wp_mail', function ( $mail ) { | |
| if ( defined( 'WP_DEBUG' ) && true == WP_DEBUG ) { | |
| error_log( 'Email - wp_mail about the send email : ' . print_r( $mail, true ) ); | |
| } | |
| }, | |
| 10, | |
| 1 | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment