[TYPO3-mvc] Mailing from the scheduler
Tobias Liebig
tobias.liebig at typo3.org
Wed Feb 6 15:41:14 CET 2013
Hej,
compared with a MailService i did some time ago, i have this additional line of code, right before rendering the view:
$emailView->getRequest()->setControllerExtensionName($this->extensionName);
Maybe that helps.
kind regards
Tobias
Am 05.02.2013 um 22:02 schrieb Lars Nieuwenhuizen <lars.nieuwenhuizen at me.com>:
> Good day,
>
> I have a question regarding the following:
>
> I have a scheduler class which extends Tx_Extbase_Scheduler_Task
> In this class i've created an email function:
>
> ################################
>
> /**
> * Send email
> *
> * @param User $recipient
> * @param array $sender
> * @param string $subject
> * @param string $templateName
> * @param $templateType
> * @param array $variables
> * @return boolean
> */
> protected function sendTemplateEmail($recipient, array $sender, $subject, $templateName, $templateType, array $variables = array()) {
> $emailView = $this->objectManager->create('Tx_Fluid_View_StandaloneView');
>
> $emailView->setFormat($templateType);
>
> $templateRootPath = t3lib_div::getFileAbsFileName('EXT:extension/Resources/Private/Templates/');
> $templateLayoutRootPath = t3lib_div::getFileAbsFileName('EXT:extension/Resources/Private/Layouts/');
> $templatePartialRootPath = t3lib_div::getFileAbsFileName('EXT:extension/Resources/Private/Partials/');
>
> $templatePathAndFilename = $templateRootPath . 'Email/' . $templateName . '.html';
> $emailView->setLayoutRootPath($templateLayoutRootPath);
> $emailView->setPartialRootPath($templatePartialRootPath);
> $emailView->setTemplatePathAndFilename($templatePathAndFilename);
>
> $emailView->assignMultiple($variables);
> $emailView->assign('webUser', $recipient);
>
> $emailBody = $emailView->render();
>
> $message = t3lib_div::makeInstance('t3lib_mail_Message');
>
> $message->setTo($recipient->getEmail())
> ->setFrom($sender)
> ->setSubject($subject);
> // Plain text example
> $message->setBody($emailBody, 'text/' . $templateType);
>
> $message->send();
> return $message->isSent();
> }
>
> ################################
>
> When the mail is sent, i receive the email without any of the language labels. My urls that fluid should format are messed up.
> The entire email is wasted… Probably because it is all outside of the scope. Is there any way to make this work?
>
> Thanks in advance,
>
> Lars Nieuwenhuizen
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
--
Tobias Liebig
TYPO3 Core Team member
TYPO3 .... inspiring people to share!
Get involved: typo3.org
http://bit.ly/supportTYPO3
More information about the TYPO3-project-typo3v4mvc
mailing list