Make WordPress Core

Opened 2 months ago

Last modified 7 weeks ago

#53826 new enhancement

wp_mail_succeeded action in wp_mail()

Reported by: birgire Owned by:
Milestone: 5.9 Priority: normal
Severity: normal Version:
Component: Mail Keywords: has-patch
Focuses: Cc:


To complement the wp_mail_failed action in wp_mail() we could add the wp_mail_succeeded action.

Here's a suggestion to use e.g.:

$status = $phpmailer->send();

if ( $status ) {

	$mail_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' );

	 * Fires after PHPMailer has successfully sent a mail.
	 * @since x.y.z
	 * @param array $mail_data An array containing the mail recipient, subject, message, headers, and attachments.
	do_action( 'wp_mail_succeeded', $mail_data );		

in wp_mail() instead of:

return $phpmailer->send();

ps: In BuddyPress we have e.g. both bp_send_email_failure and bp_send_email_success actions.

Change History (3)

This ticket was mentioned in PR #1535 on WordPress/wordpress-develop by donmhico.

8 weeks ago

  • Keywords has-patch added

This PR adds wp_mail_succeeded action.

Trac ticket: https://core.trac.wordpress.org/ticket/53826

#2 @birgire
7 weeks ago

@donmhico Thanks for the patch, it looks good.

#3 @SergeyBiryukov
7 weeks ago

  • Milestone changed from Awaiting Review to 5.9
Note: See TracTickets for help on using tickets.