[TYPO3-mvc] Sending HTML mail with template - best practices?
Mario Beiser
mariobeiser at googlemail.com
Wed May 26 22:37:00 CEST 2010
In article
<mailman.19277.1274891214.610.typo3-project-typo3v4mvc at lists.typo3.org>,
"Nikolas Hagelstein" <lists at shr-now.de> wrote:
> Hi,
>
> Within the controller:
> $html = $this->view->render('whatever');
>
> Pass the markup over to your mail code et. Voila.
>
> Conceptual I would create a mail service an move all sending functionality
> to it.
>
> Cheers,
> Nikolas
Hi Nicolas,
thanks for your answer.
Just checked it and thought of something like this:
$renderer = t3lib_div::makeInstance('Tx_Fluid_View_TemplateView');
$controllerContext =
t3lib_div::makeInstance('Tx_Extbase_MVC_Controller_ControllerContext');
$controllerContext->setRequest(t3lib_div::makeInstance('Tx_Extbase_MVC_Re
quest'));
$renderer->setControllerContext($controllerContext);
$template = t3lib_extMgm::extPath($this->extKey) .
'Resources/Private/register.tmpl';
$renderer->setTemplatePathAndFilename($template);
$renderer->assign('helloworld', $helloworld);
$rendered = $renderer->render();
then pass the $rendered to mail mail service.
Works fine for me...
Cheers
Mario
More information about the TYPO3-project-typo3v4mvc
mailing list