[wp-trac] [WordPress Trac] #38028: Send emails via an action

WordPress Trac noreply at wordpress.org
Mon Sep 12 20:55:21 UTC 2016


#38028: Send emails via an action
-------------------------+-----------------------------
 Reporter:  markcallen   |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Mail         |    Version:  3.3
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 There are a number of ways that you may want to interact with core emails
 in WordPress. To name two
 * Use a different server to send (e.g. to benefit from DKIM/SPF)
 * Use custom templates, HTML, multipart etc.

 Currently solutions to achieve these things are not ideal. Pluggable
 functions leave exposure to other core changes and leave no scope for a
 'fallback' to default if it is necessary.

 Filters for content are inconsistently (if at all) applied leaving some
 messages totally inaccessible to developers, save through the wp_mail
 filter - which is hacky at best (try catching a translated message).

 My proposal is relatively simple - send all emails in core through an
 action hook.

 `do_action( 'wp_mail_{email_id}', $args );`

 `$args` of course would carry the necessary elements for the dynamic parts
 of a message.

 An call add_action can then exactly replace what is being done at present
 to generate the message and make the `wp_mail` call.

 Any developer that wants to interact with the message can then simply
 remove the core action and add their own - to alter the message and/or
 send using an alternative mechanism to `wp_mail`, falling back to it if
 necessary. Possibilities for developers are then endless.

 `wp_mail` stays in tact and as the hook call replaces current
 functionality there is no issue with backward compatibility - all existing
 filters can stay in place.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38028>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list