/** * @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(); }
/** * Executes this finisher * @see AbstractFinisher::execute() * * @return void * @throws FinisherException */ protected function executeInternal() { $formRuntime = $this->finisherContext->getFormRuntime(); $standaloneView = $this->initializeStandaloneView(); $standaloneView->assign('form', $formRuntime); $message = $standaloneView->render(); $subject = $this->parseOption('subject'); $recipientAddress = $this->parseOption('recipientAddress'); $recipientName = $this->parseOption('recipientName'); $senderAddress = $this->parseOption('senderAddress'); $senderName = $this->parseOption('senderName'); $replyToAddress = $this->parseOption('replyToAddress'); $carbonCopyAddress = $this->parseOption('carbonCopyAddress'); $blindCarbonCopyAddress = $this->parseOption('blindCarbonCopyAddress'); $format = $this->parseOption('format'); $testMode = $this->parseOption('testMode'); if ($subject === null) { throw new FinisherException('The option "subject" must be set for the EmailFinisher.', 1327060320); } if ($recipientAddress === null) { throw new FinisherException('The option "recipientAddress" must be set for the EmailFinisher.', 1327060200); } if ($senderAddress === null) { throw new FinisherException('The option "senderAddress" must be set for the EmailFinisher.', 1327060210); } $mail = new \TYPO3\SwiftMailer\Message(); $mail->setFrom(array($senderAddress => $senderName))->setTo(array($recipientAddress => $recipientName))->setSubject($subject); if ($replyToAddress !== null) { $mail->setReplyTo($replyToAddress); } if ($carbonCopyAddress !== null) { $mail->setCc($carbonCopyAddress); } if ($blindCarbonCopyAddress !== null) { $mail->setBcc($blindCarbonCopyAddress); } if ($format === self::FORMAT_PLAINTEXT) { $mail->setBody($message, 'text/plain'); } else { $mail->setBody($message, 'text/html'); } if ($testMode === true) { \Neos\Flow\var_dump(array('sender' => array($senderAddress => $senderName), 'recipient' => array($recipientAddress => $recipientName), 'replyToAddress' => $replyToAddress, 'carbonCopyAddress' => $carbonCopyAddress, 'blindCarbonCopyAddress' => $blindCarbonCopyAddress, 'message' => $message, 'format' => $format), 'E-Mail "' . $subject . '"'); } else { $mail->send(); } }