Make WordPress Core

Changeset 34221


Ignore:
Timestamp:
09/15/2015 11:50:30 PM (9 years ago)
Author:
jorbin
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/pluggable.php

    r34129 r34221  
    535535        return $phpmailer->Send();
    536536    } catch ( phpmailerException $e ) {
     537
     538        $mail_error_data = compact( $to, $subject, $message, $headers, $attachments );
     539        /**
     540         * Fires after a phpmailerException is caught
     541         *
     542         * @since 4.4.0
     543         *
     544         * @param WP_Error A WP_Error object with the phpmailerException code, message and an array
     545         *                 containing the mail recipient, subject, message, headers and attachments
     546         */
     547        do_action( 'wp_mail_failed', new WP_Error( $e->getCode(), $e->getMessage(), $mail_error_data ) );
     548
    537549        return false;
    538550    }
Note: See TracChangeset for help on using the changeset viewer.