wp_mail_failed
Fires when wp_mail() fails to send an email.
Usage
add_action( 'wp_mail_failed', 'wp_kama_mail_failed_action' );
/**
* Function for `wp_mail_failed` action-hook.
*
* @param WP_Error $error A WP_Error object with the PHPMailer\PHPMailer\Exception message, and an array containing the mail recipient, subject, message, headers, attachments, and embeds.
*
* @return void
*/
function wp_kama_mail_failed_action( $error ){
// action...
}
- $error(WP_Error)
- An instance of the WP_Error class containing the specified error and other data.
Examples
#1 Enable SMTP for Beget and debug errors
Changelog
| Since 4.4.0 | Introduced. |
Where the hook is called
wp_mail_failed
wp-includes/pluggable.php 665
do_action( 'wp_mail_failed', new WP_Error( 'wp_mail_failed', $e->getMessage(), $mail_data ) );
wp-includes/pluggable.php 455
do_action( 'wp_mail_failed', new WP_Error( 'wp_mail_failed', $e->getMessage(), $mail_error_data ) );