From 6d668807fbad660ea741646bc5b6d2d244b3e39b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 25 Apr 2016 16:02:57 +0200 Subject: [PATCH 1/2] Allow automatic dependency injection for OCP\Mail\Mailer --- lib/private/AppFramework/DependencyInjection/DIContainer.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php index f74fe4aeb9..2951ee536d 100644 --- a/lib/private/AppFramework/DependencyInjection/DIContainer.php +++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php @@ -175,6 +175,10 @@ class DIContainer extends SimpleContainer implements IAppContainer { return $this->getServer()->getMimeTypeDetector(); }); + $this->registerService('OCP\\Mail\\IMailer', function() { + return $this->getServer()->getMailer(); + }); + $this->registerService('OCP\\INavigationManager', function($c) { return $this->getServer()->getNavigationManager(); }); From a18c8a7da0551b4afab913c1b60d2f8f9ab154a7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 25 Apr 2016 16:03:20 +0200 Subject: [PATCH 2/2] Fix the syntax and methods in the sample --- lib/public/mail/imailer.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/public/mail/imailer.php b/lib/public/mail/imailer.php index 61eb895752..e3c751277a 100644 --- a/lib/public/mail/imailer.php +++ b/lib/public/mail/imailer.php @@ -32,9 +32,10 @@ use OC\Mail\Message; * $mailer = \OC::$server->getMailer(); * $message = $mailer->createMessage(); * $message->setSubject('Your Subject'); - * $message->setFrom(array('cloud@domain.org' => 'ownCloud Notifier'); - * $message->setTo(array('recipient@domain.org' => 'Recipient'); - * $message->setBody('The message text'); + * $message->setFrom(['cloud@domain.org' => 'ownCloud Notifier']); + * $message->setTo(['recipient@domain.org' => 'Recipient']); + * $message->setPlainBody('The message text'); + * $message->setHtmlBody('The message text'); * $mailer->send($message); * * This message can then be passed to send() of \OC\Mail\Mailer