Action hook 'wp_mail_failed'

in WP Core File wp-includes/pluggable.php at line 582

View Source

wp_mail_failed

Action Hook
Description
Fires after a PHPMailer\PHPMailer\Exception is caught.

Hook Information

File Location wp-includes/pluggable.php View on GitHub
Hook Type Action
Line Number 582

Hook Parameters

Type Name Description
WP_Error $error A WP_Error object with the PHPMailer\PHPMailer\Exception message, and an array containing the mail recipient, subject, message, headers, and attachments.

Usage Examples

Basic Usage
<?php
// Hook into wp_mail_failed
add_action('wp_mail_failed', 'my_custom_function', 10, 1);

function my_custom_function($error) {
    // Your custom code here
}

Source Code Context

wp-includes/pluggable.php:582 - How this hook is used in WordPress core
<?php
 577  			 * @since 4.4.0
 578  			 *
 579  			 * @param WP_Error $error A WP_Error object with the PHPMailer\PHPMailer\Exception message, and an array
 580  			 *                        containing the mail recipient, subject, message, headers, and attachments.
 581  			 */
 582  			do_action( 'wp_mail_failed', new WP_Error( 'wp_mail_failed', $e->getMessage(), $mail_data ) );
 583  
 584  			return false;
 585  		}
 586  	}
 587  endif;

PHP Documentation

<?php
/**
			 * Fires after a PHPMailer\PHPMailer\Exception is caught.
			 *
			 * @since 4.4.0
			 *
			 * @param WP_Error $error A WP_Error object with the PHPMailer\PHPMailer\Exception message, and an array
			 *                        containing the mail recipient, subject, message, headers, and attachments.
			 */
Quick Info
  • Hook Type: Action
  • Parameters: 1
  • File: wp-includes/pluggable.php
Related Hooks

Related hooks will be displayed here in future updates.