/** * Send email * * @param string $emailName Email name * @param array $context Context * @param string $receiverEmail Receiver email */ protected function sendEmail($emailName, array $context, $receiverEmail) { $page = $this->pageRepository->findOneBy(['name' => $emailName]); if ($page instanceof PageInterface) { $template = $this->templateLocator->locate(':email.html.twig'); $resolvedPage = $this->twig->render($template, array_merge(['title' => $page->getTitle(), 'content' => $page->getContent()], $context)); $message = $this->mailer->createMessage()->setSubject($page->getTitle())->setFrom($this->store->getEmail())->setTo($receiverEmail)->setBody($resolvedPage, 'text/html'); $this->mailer->send($message); } }