[wp-trac] [WordPress Trac] #18493: HTML E-Mails

WordPress Trac wp-trac at lists.automattic.com
Sat Jan 28 10:37:53 UTC 2012


#18493: HTML E-Mails
---------------------------+-----------------------------
 Reporter:  aaroncampbell  |       Owner:  westi
     Type:  enhancement    |      Status:  reviewing
 Priority:  normal         |   Milestone:  Future Release
Component:  Mail           |     Version:  3.2
 Severity:  normal         |  Resolution:
 Keywords:  3.4-early      |
---------------------------+-----------------------------

Comment (by westi):

 I've been thinking about this a lot so sorry for not getting back to you
 sooner and for the length of this comment.

 So far I have seen a solution which I feel comfortable with in core so I
 thought it was probably best to set out some goals as I see them for the
 first version of HTML emails in core and then we can discuss how best to
 move forward.

  1 Update WordPress so that all the emails it sends have a HTML version.
  2 Provide an API that makes it really easy for plugins to send HTML
 emails.
  3 Provide an API that makes it really easy for themes to customise the
 styling of the emails to integrate with a site design.

 I think the key issue here is how can we make (2) and (3) as simple as
 possible and I think there are a few options/pieces to the puzzle:

  1 How much should be templates versus "magic" - i.e. Do we need to have
 HTML versions of every email body we send or can we just auto-tag the text
 using autop / a simple markup language.
  2 Should we use php templates which print the output and output buffering
 or functions which return the HTML.
  3 Can the emails be made to be themable enough by just letting the
 header/footer be customisable

 I think that however deep we go into templating to make this truly
 extendable by plugins and overridable by themes we should start small and
 then build up as we find problems issues we need to address and discuss
 and address each one.

 As such I think the following phased approach would be a good way to
 address HTML emails for core:

 Phase 1 - This may be starting too small but also should be something
 someone could pull together in a couple of hours as a proof-of-
 not-a-concept ;)

 Create an api function {{{wp_html_mail( $to, $subject, $message, $headers
 = '', $attachments = array() )}}} which mirrors the API of {{{wp_mail()}}}
 but takes the message and wraps in up into a nice HTML blanket.
 This api has filters which allow a theme to do simple child theming of the
 emails:
  * Replace the CSS that we output in the header of the email - I believe
 based on my understanding of the limits of HTML emails this will allow for
  * Replace the logo used in the email to identify the site.

 The header and footer html would not be customisable.

 Then we can review what each of the emails core generates looks like with
 this simple api and see if we are happy or need to move on to Phase 2

 Phase 2 - Make things more flexible, extensible.

 Slowly extend the api to support templates, investigating the following:
  * Can we make a solely function based template system where we have
 default functions in core and themes can replace them (either through a
 registration API or like pluggable functions)?
  * Can we make an output buffering based solution not be ugly?
  * Should we implement a simplified templating language?

 I think when we review these we will find that on balance an output
 buffering based template system is best because it gives theme developers
 the most familiar experience and gives them full control. However, I would
 still like to keep simplicity in mind and if we can come up with a lightly
 templated solution which doesn't give full control over the content area
 of the emails - so we can keep a common format and just makes it easier to
 change the general style/header/footer and for plugins to make use of this
 style/header/footer with there own custom bodies then we may have found
 the perfect middle ground ;)

 I know this sounds a lot like starting from scratch but I don't see it
 that way we have got a lot of excellent work already done dealing with the
 intricacies of getting HTML emails that look nice in email clients and the
 discussion now is more how we can adapt these to make them integrate into
 core in the best way.

 It would be great if we could all get together in IRC early next week to
 discuss - I'm around most week days 9am-5pm UTC.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/18493#comment:22>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list