コード例 #1
0
 /**
  * @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();
 }
コード例 #2
0
 /**
  * Sends email for comment approval
  *
  * @param \Lelesys\Plugin\News\Domain\Model\Comment $comment Comment for approval
  * @param \Lelesys\Plugin\News\Domain\Model\News $news The news
  * @return void
  */
 public function sendCommentApprovalNotification(\Lelesys\Plugin\News\Domain\Model\Comment $comment, \Lelesys\Plugin\News\Domain\Model\News $news)
 {
     $this->standaloneView->setTemplatePathAndFilename(FLOW_PATH_PACKAGES . $this->settings['notifications']['emailTemplatePath']);
     $this->standaloneView->assign('comment', $comment);
     $this->standaloneView->assign('adminEmail', $news->getCreatedBy());
     $this->standaloneView->assign('news', $news);
     $emailBody = $this->standaloneView->render();
     $toEmail = $news->getCreatedBy()->getPrimaryElectronicAddress()->getIdentifier();
     $mail = new \TYPO3\SwiftMailer\Message();
     $mail->setFrom(array($this->settings['notifications']['senderAddress'] => $this->settings['notifications']['senderName']))->setContentType('text/html')->setTo($toEmail)->setSubject('Comment Approval')->setBody($emailBody)->send();
 }
コード例 #3
0
ファイル: EmailFinisher.php プロジェクト: neos/form
 /**
  * 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();
     }
 }
コード例 #4
0
 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);
 }
コード例 #5
0
 /**
  * Helper function to instantiate SwiftMailer and effectively send the mail
  * out to the recipient.
  *
  * @param string the recipient's e-mail address
  * @param string the name of the recipient
  * @param string the message's subject
  * @param string the message's body
  *
  * @return void
  */
 protected function sendNotificationMail($recipientEmail, $recipientName, $subject, $messageBody)
 {
     $mail = new \TYPO3\SwiftMailer\Message();
     $mail->setFrom(array($this->settings['senderEmail'] => $this->settings['senderName']))->setTo(array($recipientEmail => $recipientName))->setSubject($subject)->setBody($messageBody);
     $mail->send();
 }