#53826 closed enhancement (fixed)
wp_mail_succeeded action in wp_mail()
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 5.9 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Keywords: | has-patch commit has-dev-note | |
| Focuses: | Cc: |
Description
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.
Attachments (1)
Change History (13)
This ticket was mentioned in PR #1535 on WordPress/wordpress-develop by donmhico.
4 years ago
#1
- Keywords has-patch added
This ticket was mentioned in Slack in #core by hellofromtonya. View the logs.
4 years ago
#5
@
4 years ago
- Milestone changed from 5.9 to Future Release
Looking at the new action, 'wp_mail_succeeded', why is it in the catch and not the try? If it succeeds, it would not go into the catch.
Today is 5.9 feature freeze. With questions pending, punting this one to 6.0. As that milestone isn't available yet, setting it to Future Release. Once available, please feel free to move it into the milestone.
#6
@
4 years ago
@hellofromTonya From what I can tell, the patch is good. The wp_mail_succeeded action is in the try section, and the wp_mail_failed action is in the catch.
Whether or not this can be pulled back in for 5.9 is another question, but did want to clear up the the current PR looks OK.
#7
@
4 years ago
- Keywords commit added
- Milestone changed from Future Release to 5.9
@davidbaumwald you're right. Picture me doing a facepalm (doh). Pulling it back in and marking for commit.
#8
@
4 years ago
- Owner set to davidbaumwald
- Status changed from new to reviewing
@hellofromTonya Thanks! I'll pick this one up for review and commit.
dream-encode commented on PR #1535:
4 years ago
#10
Committed to core via changeset: https://core.trac.wordpress.org/changeset/52083
#11
@
4 years ago
- Keywords needs-dev-note added
Marking this with needs-dev-note for a small call-out on the Misc Dev note for the new filter.
This PR adds
wp_mail_succeededaction.Trac ticket: https://core.trac.wordpress.org/ticket/53826