Abschrfit des Codes:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
" ] /** * @param string $recipient * @param string $sender * @param string $senderName * @param string $subject * @param string $templateName * @param array $variables * @return boolean TRUE on success, otherwise false */ protected function sendTemplateEmail($recipient, $sender, $subject, $templateName, array $variables = array()) { $emailView = $this->objectManager->create('Tx_Fluid_View_StandaloneView'); $emailView->setFormat('html'); $extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); $templateRootPath = t3lib_div::getFileAbsFileName($extbaseFrameworkConfiguration['view']['templateRootPath']); $templatePathAndFilename = $templateRootPath . 'Email/' . $templateName . '.html'; $emailView->setTemplatePathAndFilename($templatePathAndFilename); $emailView->assignMultiple($variables); $emailBody = $emailView->render(); $recipient = array('john@doe.ch' => 'John Doe'); $sender = array('contact@example.com' => 'Example Sender'); $subject = 'Subject of the email'; $message = t3lib_div::makeInstance('t3lib_mail_Message'); $message->setTo($recipient) ->setFrom($sender) ->setSubject($subject); // Possible attachments here //foreach ($attachments as $attachment) { // $message->attach($attachment); //} // Plain text example $message->setBody($emailBody, 'text/plain'); // HTML Email #$message->setBody($emailBody, 'text/html'); $message->send(); return $message->isSent(); } |