/** * Hook that sends notifications. * * @param MailerEvent $event */ public function onMailEvent(MailerEvent $event) { $targets = []; foreach ($event->getUsers() as $user) { $targets[$user->getEmail()] = $user->getUsername(); } $message = \Swift_Message::newInstance($this->translator->trans('NOTIFICATIONS_SUBJECT', [], 'notifications')); $message->setTo($targets); $message->setFrom([$this->emailAddress => 'Sententiaregum']); $message->addPart($this->renderMailPart($event, 'txt.twig'), 'text/plain'); $message->addPart($this->renderMailPart($event, 'html.twig'), 'text/html'); $this->mailer->send($message); }