Page MenuHomePhabricator

Customizable templates for core HTML email
Open, Needs TriagePublic

Description

Problem

By default MediaWiki sends only oldfashioned plain text mails. Developers would like to easily send HTML email, with a customizable layout and design.

Who would benefit

All developers that need to customize core HTML notification mails. This is especially a need in business contexts.

Proposed solution

There could be some directory that contains an HTML template and all required resources. E.g <mediawiki>/resources/mail/default which contains body.html, header.jpg, styles.css, ...
Also the use of a library like SwiftMailer or PHPMailer should be considered.

This is a sub-task of T15303: Implement HTML e-mail support in MediaWiki.

Event Timeline

UserMailer::send() already supports sending HTML mail, just pass an array [ 'text' => $plaintext, 'html' => $html ] as the $body argument with $html being whatever HTML you want to send. It doesn't seem to support multipart/related, although I'd argue that too many images and such is annoying anyway for the types of emails MediaWiki should be sending.

Files in a "resources/mail/default" directory seem like they would not be very amenable to i18n via translatewiki.

Yes, you are right. And also does "Extension:Echo" support some kind of HTML mailing. But it is very difficult to customize this at the moment. Having template and resource files in a "resources/mail/default" directory should not be a problem for I18N/TranslateWiki, as special placeholders (like <div data-messagekey="mail-greeting">) could be substituted by values from the MediaWiki Message API when a mail gets actually send.

Are you asking to change how Echo HTML emails are configured/sent, or non-Echo HTML emails? There should be separate tasks for those two issues.

Note that Echo is planned to be merged into core (T128351).

This proposal is selected for the Developer-Wishlist voting round and will be added to a MediaWiki page very soon. To the subscribers, or proposer of this task: please help modify the task description: add a brief summary (10-12 lines) of the problem that this proposal raises, topics discussed in the comments, and a proposed solution (if there is any yet). Remember to add a header with a title "Description," to your content. Please do so before February 5th, 12:00 pm UTC.

@jmatazzoni would you or someone from Collaboration-Team-Triage be willing to mentor this project for Google Summer of Code 2017 or Outreachy Round 14? left a comment on T15303 as well.

The scope for this is unclear. See my above comment.

@Mattflaschen-WMF: I think MediaWiki core should feature such a system for all outgoing mails. Echo could then just build upon this system. As there is already much work done in Echo maybe some parts of it can just be moved to core. Still AFAIK Echo lacks an easy way to change the layout&design of outgoing HTML mails. One needs to explicitly set a 'formatter' class on each and every registered notification. Or am I wrong here?

EDIT: Just read that @Tgr said Echo will be merged to core anyways. So I believe that after that has happened the HTML mail formatting of the Echo subsystem should provide some configuration or hook points to allow change of layout&design.

I think this task has been way overblown in the past and can be implemented without too much difficulty. First off, the ability to send HTML email has already been implemented in the UserMailer class, so that's taken care of.

At this point I think we (someone!) should create a very simple HTML template that basically wraps the current message in <p></p> and converts the links to use proper <a> tags. Don't worry about replicating Echo's email format in core right now, that's pretty complicated. Once we have the basic groundwork in place, we can iterate and improve the HTML templates, including reconciliation with Echo..

Mattflaschen-WMF renamed this task from Provide an easy to use HTML mail system to Customizable templates for HTML email.Mar 2 2017, 7:32 PM
Mattflaschen-WMF updated the task description. (Show Details)

I've rescoped to be about customizable core HTML templates, per above, and will make it a subtask of T15303.

Mattflaschen-WMF renamed this task from Customizable templates for HTML email to Customizable templates for core HTML email.Mar 2 2017, 7:33 PM
Mattflaschen-WMF updated the task description. (Show Details)

It now looks like a decent Outreachy project IMO, involving a bit of design/ documentation. In the past, it looks like @Parent5446 and @Tinaj1234 were willing to mentor for the parent task. Any interest again Tyler and Tina? Anyone else interested in mentoring?