-
-
Save ionurboz/288bff17e50bbdd464bb9589787614b5 to your computer and use it in GitHub Desktop.
Debug wp_mail function. Display errors on screen
This file contains 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 | |
/** | |
* Display errors | |
*/ | |
if ( ! function_exists('debug_wpmail') ) : | |
function debug_wpmail( $result = false ) { | |
if ( $result ) | |
return; | |
global $ts_mail_errors, $phpmailer; | |
if ( ! isset($ts_mail_errors) ) | |
$ts_mail_errors = array(); | |
if ( isset($phpmailer) ) | |
$ts_mail_errors[] = $phpmailer->ErrorInfo; | |
print_r('<pre>'); | |
print_r($ts_mail_errors); | |
print_r('</pre>'); | |
} | |
endif; | |
/** | |
* Usage | |
*/ | |
$res = wp_mail($to, $subject, $message); | |
debug_wpmail($res); // Will print_r array of errors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment