[TYPO3-mvc] Mailing from the scheduler

Lars Nieuwenhuizen lars.nieuwenhuizen at me.com
Tue Feb 5 22:02:15 CET 2013


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


More information about the TYPO3-project-typo3v4mvc mailing list