Make WordPress Core

Ticket #53826: 53826.diff

File 53826.diff, 1.8 KB (added by davidbaumwald, 4 years ago)

Added disclaimer, minor spelling corrections

  • src/wp-includes/pluggable.php

     
    537537                 */
    538538                do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
    539539
     540                $mail_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' );
     541
    540542                // Send!
    541543                try {
    542                         return $phpmailer->send();
    543                 } catch ( PHPMailer\PHPMailer\Exception $e ) {
     544                        $send = $phpmailer->send();
    544545
    545                         $mail_error_data                             = compact( 'to', 'subject', 'message', 'headers', 'attachments' );
    546                         $mail_error_data['phpmailer_exception_code'] = $e->getCode();
     546                        /**
     547                         * Fires after PHPMailer has successfully sent a mail.
     548                         *
     549                         * The firing of this action does not necessarily mean that the recipient received the
     550                         * email successfully. It only means that the `send` method above was able to
     551                         * process the request without any errors.
     552                         *
     553                         * @since 5.9.0
     554                         *
     555                         * @param array $mail_data An array containing the mail recipient, subject, message, headers, and attachments.
     556                         */
     557                        do_action( 'wp_mail_succeeded', $mail_data );
    547558
     559                        return $send;
     560                } catch ( PHPMailer\PHPMailer\Exception $e ) {
     561                        $mail_data['phpmailer_exception_code'] = $e->getCode();
    548562                        /**
    549563                         * Fires after a PHPMailer\PHPMailer\Exception is caught.
    550564                         *
     
    553567                         * @param WP_Error $error A WP_Error object with the PHPMailer\PHPMailer\Exception message, and an array
    554568                         *                        containing the mail recipient, subject, message, headers, and attachments.
    555569                         */
    556                         do_action( 'wp_mail_failed', new WP_Error( 'wp_mail_failed', $e->getMessage(), $mail_error_data ) );
     570                        do_action( 'wp_mail_failed', new WP_Error( 'wp_mail_failed', $e->getMessage(), $mail_data ) );
    557571
    558572                        return false;
    559573                }