Description
Triggered when an email from Gravity Forms fails to send.
Usage
add_action( 'gform_send_email_failed', 'my_function', 10, 3 );
Parameters
- $error object
A instance of WP_Error for the error returned from the email failure.
-
$email array
An array containing details of the email that failed to send. It includes the following keys: ‘from’, ‘to’, ‘bcc’, ‘reply_to’, ‘subject’, ‘message’, ‘from_name’, ‘message_format’, ‘attachments’, ‘cc’
-
$entry array
The entry object.
Examples
The example below would use WordPress core wp_mail() function to send a basic email about the failed notification. For obvious reasons, it will work only if the site is able to send other emails. If for whatever reason your server is blocking all the emails from your WordPress, you wouldn’t get this email either.
// Notification failure alert.
add_action( 'gform_send_email_failed', function ( $error, $details, $entry ) {
GFCommon::log_debug( __METHOD__ . '(): running.' );
$to = '[email protected]'; // Change this to your email address.
$subject = 'Notification failed!';
$body = "Notification email '$details[subject]' for entry #$entry[id] failed.";
wp_mail( $to, $subject, $body );
}, 10, 3 );
Source Code
This action hook is located in common.php.