Fire Action when mail exception is thrown.

new action is wp_mail_failed which contains a WP_Error object with the phpmailerException code, message and an array with the mail information. Plugins can hook in and log when mails fail to send due to a phpmailer issue.

Props soulseekah
Fixes #18926


Built from https://develop.svn.wordpress.org/trunk@34221


git-svn-id: http://core.svn.wordpress.org/trunk@34185 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Aaron Jorbin 2015-09-15 23:51:23 +00:00
parent 628caeb487
commit 1bd52ae1aa
2 changed files with 13 additions and 1 deletions

View File

@ -534,6 +534,18 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array()
try {
return $phpmailer->Send();
} catch ( phpmailerException $e ) {
$mail_error_data = compact( $to, $subject, $message, $headers, $attachments );
/**
* Fires after a phpmailerException is caught
*
* @since 4.4.0
*
* @param WP_Error A WP_Error object with the phpmailerException code, message and an array
* containing the mail recipient, subject, message, headers and attachments
*/
do_action( 'wp_mail_failed', new WP_Error( $e->getCode(), $e->getMessage(), $mail_error_data ) );
return false;
}
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-alpha-34219';
$wp_version = '4.4-alpha-34221';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.