/** * @param string $purpose * @param mixed $object * @return int */ public function send($purpose, $object) { $message = new \TYPO3\SwiftMailer\Message(); $message->setSubject($this->getSubject($purpose))->setFrom($this->getSender())->setTo($this->getRecipient($object))->setBody($this->renderContent($purpose, ['value' => $object]), 'text/html'); if ($purpose !== 'participantCompleteRegistration' && isset($this->configuration['Bcc'])) { $message->setBcc([$this->configuration['Bcc']['email'] => $this->configuration['Bcc']['name']]); } return $message->send(); }
private function sendMail($from, $to, $data, $templateFile) { $template = new \TYPO3\Fluid\View\StandaloneView(); $template->setFormat('html'); $template->setTemplatePathAndFilename('resource://DRKTettnang.Homepage/Private/Templates/Mail/' . $templateFile . '.html'); $template->setPartialRootPath('resource://DRKTettnang.Homepage/Private/Partials/'); $template->assign('data', $data); $subject = trim($template->renderSection('subject')); $html = $template->render(); $body = trim($template->renderSection('body')); $html2text = new \DRKTettnang\Homepage\Vendor\Html2Text($body); $plain = $html2text->getText(); $mail = new \TYPO3\SwiftMailer\Message(); $mail->setTo($to); $mail->setFrom($from); $mail->setSubject($subject); $mail->addPart($html, 'text/html', 'utf-8'); $mail->addPart($plain, 'text/plain', 'utf-8'); $mail->send(); $this->systemLogger->log('Sent mail to ' . $to, LOG_INFO); }