{"action":"created","issue":{"url":"https://api.github.com/repos/joomla/joomla-cms/issues/19368","repository_url":"https://api.github.com/repos/joomla/joomla-cms","labels_url":"https://api.github.com/repos/joomla/joomla-cms/issues/19368/labels{/name}","comments_url":"https://api.github.com/repos/joomla/joomla-cms/issues/19368/comments","events_url":"https://api.github.com/repos/joomla/joomla-cms/issues/19368/events","html_url":"https://github.com/joomla/joomla-cms/pull/19368","id":288372038,"number":19368,"title":"[4.0][RFC] New Mailer Service Architecture","user":{"login":"mbabker","id":368545,"avatar_url":"https://avatars2.githubusercontent.com/u/368545?v=4","gravatar_id":"","url":"https://api.github.com/users/mbabker","html_url":"https://github.com/mbabker","followers_url":"https://api.github.com/users/mbabker/followers","following_url":"https://api.github.com/users/mbabker/following{/other_user}","gists_url":"https://api.github.com/users/mbabker/gists{/gist_id}","starred_url":"https://api.github.com/users/mbabker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbabker/subscriptions","organizations_url":"https://api.github.com/users/mbabker/orgs","repos_url":"https://api.github.com/users/mbabker/repos","events_url":"https://api.github.com/users/mbabker/events{/privacy}","received_events_url":"https://api.github.com/users/mbabker/received_events","type":"User","site_admin":false},"labels":[{"id":444033883,"url":"https://api.github.com/repos/joomla/joomla-cms/labels/PR-4.0-dev","name":"PR-4.0-dev","color":"ededed","default":false},{"id":31297684,"url":"https://api.github.com/repos/joomla/joomla-cms/labels/Request%20for%20Comment","name":"Request for Comment","color":"02d7e1","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-01-14T00:42:52Z","updated_at":"2018-04-17T10:54:24Z","closed_at":null,"author_association":"OWNER","pull_request":{"url":"https://api.github.com/repos/joomla/joomla-cms/pulls/19368","html_url":"https://github.com/joomla/joomla-cms/pull/19368","diff_url":"https://github.com/joomla/joomla-cms/pull/19368.diff","patch_url":"https://github.com/joomla/joomla-cms/pull/19368.patch"},"body":"### Summary of Changes\r\n\r\nRight now Joomla's mail system is essentially a subclass of the main PHPMailer class with some interesting design quirks, including:\r\n\r\n- Singleton object storage\r\n- Function signatures deviating from the parent source\r\n\r\nFor the first issue, this can be problematic as any PHP object representing an email message really should be a one-and-done object, not persisted in storage and reusable.  The second issue is just bad API design and at this point pretty difficult to fix.\r\n\r\nInstead of trying to redesign `Joomla\\CMS\\Mail\\Mail` (the subclass to PHPMailer's base class), I think we're better off introducing a service layer in front of PHPMailer so that we don't have an API that is explicitly dependent on PHPMailer (core could move to Swiftmailer or any other PHP mailing library if desired/needed) and addresses the design issues in the existing class.\r\n\r\nThis is accomplished by introducing three new interfaces to our API with implementations defaulting to PHPMailer.\r\n\r\n#### `Joomla\\CMS\\Mail\\MailerFactoryInterface`\r\n\r\nThis is the main entry point into the redesigned mail API.  Through this service factory you would create a mailer object to interface with the chosen mail package/transport.\r\n\r\n#### `Joomla\\CMS\\Mail\\MailerInterface`\r\n\r\nThis object is a \"manager\" of sorts for interacting with the underlying package/transport and is responsible for creating new messages.  In the case of our default PHPMailer implementation, it exposes the callback function to be used by default for debug statements as well.\r\n\r\n#### `Joomla\\CMS\\Mail\\MailMessageInterface`\r\n\r\nThis object represents a single email message and is the object you will be working with primarily, this is where you'd do things like set the message body or the address list.\r\n\r\n### Testing Instructions\r\n\r\nEssentially, the new API boils down to this:\r\n\r\n```php\r\nuse Joomla\\CMS\\Factory;\r\n\r\n$mailFactory = Factory::getContainer()->get('mailer.factory');\r\n\r\n$mailer = $mailFactory->createMailer();\r\n\r\n$message = $mailer->createMessage();\r\n$message->setBody('My text');\r\n$message->setSubject('Testing message');\r\n$message->addRecipient('you@example.com', 'You the Reader');\r\n$message->send();\r\n```\r\n\r\nFor more advanced cases where you might want/need to work directly with the underlying transport, the `MailMessageInterface` interface has a `getMailer` method which gives access to that object, which in the case of this default implementation is the PHPMailer class instance which the message is based on.\r\n\r\n### TODO\r\n\r\n- [ ] Finish implementation\r\n- [ ] Discuss deprecations\r\n\r\n### Documentation Changes Required\r\n\r\nTBD"},"comment":{"url":"https://api.github.com/repos/joomla/joomla-cms/issues/comments/381947053","html_url":"https://github.com/joomla/joomla-cms/pull/19368#issuecomment-381947053","issue_url":"https://api.github.com/repos/joomla/joomla-cms/issues/19368","id":381947053,"user":{"login":"brianteeman","id":1296369,"avatar_url":"https://avatars3.githubusercontent.com/u/1296369?v=4","gravatar_id":"","url":"https://api.github.com/users/brianteeman","html_url":"https://github.com/brianteeman","followers_url":"https://api.github.com/users/brianteeman/followers","following_url":"https://api.github.com/users/brianteeman/following{/other_user}","gists_url":"https://api.github.com/users/brianteeman/gists{/gist_id}","starred_url":"https://api.github.com/users/brianteeman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianteeman/subscriptions","organizations_url":"https://api.github.com/users/brianteeman/orgs","repos_url":"https://api.github.com/users/brianteeman/repos","events_url":"https://api.github.com/users/brianteeman/events{/privacy}","received_events_url":"https://api.github.com/users/brianteeman/received_events","type":"User","site_admin":false},"created_at":"2018-04-17T10:54:24Z","updated_at":"2018-04-17T10:54:24Z","author_association":"CONTRIBUTOR","body":"I cant see the usecase for that then?"}}
{"actor":{"display_login":"brianteeman"}}