Extbase - E-Mail / MailMessage: Unterschied zwischen den Versionen
Aus Wikizone
| Zeile 2: | Zeile 2: | ||
https://typo3.org/api/typo3cms/class_t_y_p_o3_1_1_c_m_s_1_1_core_1_1_mail_1_1_mail_message.html | https://typo3.org/api/typo3cms/class_t_y_p_o3_1_1_c_m_s_1_1_core_1_1_mail_1_1_mail_message.html | ||
| + | |||
| + | http://t3-developer.com/extbase-fluid/extensions-erweitern/e-mail-versand-aus-extensions/mailversand/ | ||
| + | |||
| + | http://www.benny-vs-web.de/typo3/extbase-fluid-zum-rendern-von-e-mail-templates-verwenden/ | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
Aktuelle Version vom 29. Juli 2015, 13:07 Uhr
https://typo3.org/api/typo3cms/class_t_y_p_o3_1_1_c_m_s_1_1_core_1_1_mail_1_1_mail_message.html
http://www.benny-vs-web.de/typo3/extbase-fluid-zum-rendern-von-e-mail-templates-verwenden/
protected function sendTemplateEmail(array $recipient, array $sender, $subject, $templateName, array $variables = array()) {
/** @var \TYPO3\CMS\Fluid\View\StandaloneView $emailView */
$emailView = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
$extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(
\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$templateRootPath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName(
$extbaseFrameworkConfiguration['view']['templateRootPath']);
$templatePathAndFilename = $templateRootPath . 'Email/' . $templateName . '.html';
$emailView->setTemplatePathAndFilename($templatePathAndFilename);
$emailView->assignMultiple($variables);
$emailBody = $emailView->render();
/** @var $message \TYPO3\CMS\Core\Mail\MailMessage */
$message = $this->objectManager->get('TYPO3\\CMS\\Core\\Mail\\MailMessage');
$message->setTo($recipient)
->setFrom($sender)
->setSubject($subject);
// Possible attachments here
//foreach ($attachments as $attachment) {
// $message->attach(\Swift_Attachment::fromPath($attachment));
//}
// Plain text example
$message->setBody($emailBody, 'text/plain');
// HTML Email
#$message->setBody($emailBody, 'text/html');
$message->send();
//print DebuggerUtility::var_dump( $message );
return $message->isSent();
}