Commit aed55ee2 authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Email is now rendered via fluid

parent 8e236437
......@@ -85,33 +85,17 @@ class MailTemplateService {
$registerArray = MailTemplateService::getRegisterArray();
$templateEntry = $registerArray[$extensionKey][$templateKey];
$templateFileContents = file_get_contents(
$templateEntry['templatePath'] . $language . '.sg_mail.locallang.html'
);
$body = MailTemplateService::injectEmailContent($templateFileContents, $content);
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$emailView = $objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
$emailView->setTemplatePathAndFilename($templateEntry['templatePath'] . $language . '.sg_mail.locallang.html');
Please register or sign in to reply
$emailView->assignMultiple($content);
$emailBody = $emailView->render();
$mail = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
$mail->setFrom($fromAddress);
$mail->setTo($toAddress);
$mail->setSubject($subject);
$mail->setBody($body);
$mail->setBody($emailBody, 'text/html');
$mail->send();
}
/**
* injects content into template
*
* @param string $templateContent
* @param array $marker
* @return string
*/
private static function injectEmailContent($templateContent, array $content) {
foreach ($content as $marker => $value) {
str_replace('{' . $marker . '}', $value, $templateContent);
}
return $templateContent;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment