Requests for comment/UserMailer refactor
UserMailer refactor | |
---|---|
Component | General |
Creation date | |
Author(s) | Owen Davis |
Document status | declined |
Summary
[edit]Wikia has made a lot of modifications to the UserMailer. We have added HTML mail support, added mail categories, priorities for delivery and attachments, changed many preferences and defaults, added many new mail types and changed the backend to support an asynchronous mail queue. We feel that mail should generally be more “event” driven in core, and there could be a simple default mailer backend implementation that just receives all the data necessary to build an email. That would allow us to just write our own mail backend instead of having to heavily modify core. Additionally the EmailNotification class is responsible for composing and sending mail and it has a lot of business logic specific to the Foundation workflow and it's not easy to override. We have added hooks and changed basic logic in these classes.
Proposal
[edit]The main changes were related to adding new parameters to the send() function, and the cascading consequences of that addition.
+ * (<Wikia>
+ * $body can be array with text and html version of email message, and also can contain attachements
+ * $body = array('text' => 'Email text', 'html' => '<b>Email text</b>')
+ * </Wikia>)
* @param $replyto MailAddress: optional reply-to email (default: null).
* @param $contentType String: optional custom Content-Type (default: text/plain; charset=UTF-8)
+ * @param $contentType String: optional custom Content-Type
+ * @param $category String: optional category for statistic (added by Wikia)
+ * @param $priority int: optional priority for email (added by Wikia)
+ * @param $attachements Array: optional list of files to send as attachements (added by Wikia)
* @return Status object
*/
-public static function send( $to, $from, $subject, $body, $replyto = null, $contentType = 'text/plain; charset=UTF-8' ) {
+public static function send( $to, $from, $subject, $body, $replyto = null, $contentType = null, $category='UserMailer',
+$priority = 0, $attachements = array() ) {
We could just refactor this to follow mediawiki coding practices and merge it to core pretty easily. We could also rewrite the UserMailer entirely from scratch.
See also
[edit]- Declined RFC/Third-party components about replacing the UserMailer class with Swift_Mailer which would have accomplished the same goal and evaluated in the VERP project in 2014, see phab:T65483.
- phab:T3932 (old, outdated catch-all ticket superseded by the general MediaWiki-Email component)