diff options
author | Arne Hamann <kontakt+github@arne.email> | 2019-03-16 02:29:03 +0100 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-03-24 20:57:27 +0100 |
commit | a16aa995866d3319d9f848e0d5811786fad2f223 (patch) | |
tree | 0bf8b897114b43c3708573badbf48867034d556a /lib/private/Mail/Mailer.php | |
parent | 3e338c907533dd77599b576ecfadd44b3d1a9855 (diff) | |
download | nextcloud-server-a16aa995866d3319d9f848e0d5811786fad2f223.tar.gz nextcloud-server-a16aa995866d3319d9f848e0d5811786fad2f223.zip |
Added Hook before Message is send
Signed-off-by: Arne Hamann <kontakt+github@arne.email>
Diffstat (limited to 'lib/private/Mail/Mailer.php')
-rw-r--r-- | lib/private/Mail/Mailer.php | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/private/Mail/Mailer.php b/lib/private/Mail/Mailer.php index df5f2687daa..47a7f8a7c9d 100644 --- a/lib/private/Mail/Mailer.php +++ b/lib/private/Mail/Mailer.php @@ -12,6 +12,7 @@ declare(strict_types=1); * @author Lukas Reschke <lukas@statuscode.ch> * @author Morris Jobke <hey@morrisjobke.de> * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Arne Hamann <github@arne.email> * * @license AGPL-3.0 * @@ -34,6 +35,7 @@ namespace OC\Mail; use Egulias\EmailValidator\EmailValidator; use Egulias\EmailValidator\Validation\RFCValidation; use OCP\Defaults; +use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; use OCP\IL10N; use OCP\ILogger; @@ -42,6 +44,8 @@ use OCP\Mail\IAttachment; use OCP\Mail\IEMailTemplate; use OCP\Mail\IMailer; use OCP\Mail\IMessage; +use OCP\Mail\Events\BeforeMessageSent; + /** * Class Mailer provides some basic functions to create a mail message that can be used in combination with @@ -74,6 +78,8 @@ class Mailer implements IMailer { private $urlGenerator; /** @var IL10N */ private $l10n; + /** @var IEventDispatcher */ + private $dispatcher; /** * @param IConfig $config @@ -81,17 +87,20 @@ class Mailer implements IMailer { * @param Defaults $defaults * @param IURLGenerator $urlGenerator * @param IL10N $l10n + * @param IEventDispatcher $dispatcher */ public function __construct(IConfig $config, ILogger $logger, Defaults $defaults, IURLGenerator $urlGenerator, - IL10N $l10n) { + IL10N $l10n, + IEventDispatcher $dispatcher) { $this->config = $config; $this->logger = $logger; $this->defaults = $defaults; $this->urlGenerator = $urlGenerator; $this->l10n = $l10n; + $this->dispatcher = $dispatcher; } /** @@ -182,6 +191,9 @@ class Mailer implements IMailer { $mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($mailLogger)); } + + $this->dispatcher->dispatchTyped(new BeforeMessageSent($message)); + $mailer->send($message->getSwiftMessage(), $failedRecipients); // Debugging logging |