|
/ Documentation /Developer Hooks & Events/ suredonation_email_sent Action Hook

suredonation_email_sent Action Hook

Overview

The suredonation_email_sent action fires immediately after each SureDonation notification email send attempt. It fires for both successful and failed sends, making it useful for logging deliverability or triggering fallbacks.

Hook Signature

do_action( 'suredonation_email_sent', $donation_id, $to_email, $sent, $notification_name );

Parameters

  • $donation_id _(int)_ – The donation the email relates to. Defaults to 0 when no donation is associated.
  • $to_email _(string)_ – The recipient email address (already validated).
  • $sent _(bool)_ – The return value of wp_mail(): true if the mailer accepted the message, false on failure.
  • $notification_name _(string)_ – The notification’s human-readable display name (not a machine ID). Empty string if unset.

Usage

add_action( 'suredonation_email_sent', 'your_custom_function', 10, 4 );

function your_custom_function( $donation_id, $to_email, $sent, $notification_name ) {

    // Your custom logic here.

}

Example

add_action( 'suredonation_email_sent', 'mysite_log_email_failures', 10, 4 );

function mysite_log_email_failures( $donation_id, $to_email, $sent, $notification_name ) {

    if ( ! $sent ) {

        error_log( sprintf(

            'SureDonation email "%s" FAILED for donation #%d to %s',

            $notification_name,

            $donation_id,

            $to_email

        ) );

    }

}

Related Hooks

  • suredonation_email_smart_tags
  • suredonation_default_email_notifications
Was this doc helpful?
What went wrong?

We don't respond to the article feedback, we use it to improve our support content.

Need help? Contact Support
Table of Contents
Scroll to Top