Opened 4 years ago
Last modified 5 months ago
#53829 new feature request
Add unique keywords for wp_mail calls to categorize it
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Keywords: | 2nd-opinion | |
| Focuses: | Cc: |
Description
Here's a suggestion to add unique keywords (handles) for wp_mail() calls to better categorize it, like: namespace:component/to/subject, if we simulate the block names structure, just to mention one possibility.
Examples: wp:login/user/retrieve_password or wp:login/site_admin/new_user where wp is the namespace for WordPress core and plugins could use their own.
These might also be in separate array arguments, instead of a single string.
This would help targeting a single email or group of emails.
It might be easier to implement if wp_mail() would support a single array of arguments: wp_mail( $args )
ps: Helpful list of core emails:
Change History (4)
#2
@
4 years ago
Thanks for your feedback @TimothyBlynJacobs, yes I've been trying to find a way to categorize emails for a little email traffic plugin and found this to be missing :-)
ps: On a similar note, instead of using a pre_wp_mail hook trick to get the success/failure output of wp_mail I've also suggested an new succeeded mail action here: #53826 that might help email loggers.
#3
@
2 years ago
Great idea. Being able to know the context of the call to wp_mail() would open up a lot of possibilities.
#4
@
5 months ago
- Keywords 2nd-opinion added
- Type changed from enhancement to feature request
This was already commented on before, here #49661 and in fact it was providing a patch with something similar, not the exact format that is proposed here, but something like this:
'id' => 'delete_site_email', 'group' => 'ms',
Which anyway, would be valid for the purposes stated here.
I had this proposal on my notes, and definitely this could be a great head start instead of taking #49661 as a whole, because this ticket is tackling so many things that it's going to be difficult to merge that any day with how much complexity it's bringing.
It might be easier to implement if wp_mail() would support a single array of arguments: wp_mail( $args )
The idea of switching to this is not feasible because it will bring a ton of backwards compatibility issues with a single parameter unless we choose to , either , deprecate the wp_mail pluggable in exchange for encapsulating the whole mailing functionality into a fully featured class exactly as proposed in the former ticket, or simply use the wp_mail function as the final function for the class like in the proposed ticket. Either way could definitely enhance the extensibility of the mail functionality with things like this (without having to touch the wp_mail function`).
I agree this would be a very helpful feature for better logging and could also provide additional utility to the existing filters in
wp_mail().