/** * Add html and plain text bodies or only plain text if html is empty. * * @param \Swift_Message $message The swiftmailer message * @param MailRenderedInterface $mailRendered The rendered mail */ protected function addBodies(\Swift_Message $message, MailRenderedInterface $mailRendered) { $textPlain = $mailRendered->getBody(); $html = $mailRendered->getHtmlBody(); if (null === $html) { $message->setBody($textPlain, 'text/plain'); return; } $message->setBody($html, 'text/html'); if (null !== $textPlain) { $message->addPart($textPlain, 'text/plain'); } }
/** * {@inheritdoc} */ public function filter(MailRenderedInterface $mailRendered) { $cssToInlineStyles = new CssToInlineStyles(); $mailRendered->setHtmlBody($cssToInlineStyles->convert($mailRendered->getHtmlBody())); }