Beispiel #1
0
 /**
  * This is the main-function for sending Mails
  *
  * @param array $mailTo
  * @param array $mailFrom
  * @param string $subject
  * @param string $emailBody
  *
  * @return integer the number of recipients who were accepted for delivery
  */
 public function send($mailTo, $mailFrom, $subject, $emailBody)
 {
     if (!($mailTo && is_array($mailTo) && GeneralUtility::validEmail(key($mailTo)))) {
         $this->log->error('Given mailto email address is invalid.', $mailTo);
         return FALSE;
     }
     if (!($mailFrom && is_array($mailFrom) && GeneralUtility::validEmail(key($mailFrom)))) {
         $mailFrom = MailUtility::getSystemFrom();
     }
     /* @var $message \TYPO3\CMS\Core\Mail\MailMessage */
     $message = $this->objectManager->get('TYPO3\\CMS\\Core\\Mail\\MailMessage');
     $message->setTo($mailTo)->setFrom($mailFrom)->setSubject($subject)->setCharset(\TYPO3\T3extblog\Utility\GeneralUtility::getTsFe()->metaCharset);
     // send text or html emails
     if (strip_tags($emailBody) === $emailBody) {
         $message->setBody($emailBody, 'text/plain');
     } else {
         $message->setBody($emailBody, 'text/html');
     }
     if (!$this->settings['debug']['disableEmailTransmission']) {
         $message->send();
     }
     $logData = array('mailTo' => $mailTo, 'mailFrom' => $mailFrom, 'subject' => $subject, 'emailBody' => $emailBody, 'isSent' => $message->isSent());
     $this->log->dev('Email sent.', $logData);
     return $logData['isSent'];
 }
 /**
  * Notify the blog admin
  *
  * @param Comment $comment
  * @param string $emailTemplate
  *
  * @return    void
  */
 protected function notifyAdmin(Comment $comment, $emailTemplate = 'AdminNewCommentMail.txt')
 {
     $settings = $this->settings['subscriptionManager']['admin'];
     if (!$settings['enable']) {
         return;
     }
     if (!(is_array($settings['mailTo']) && strlen($settings['mailTo']['email']) > 0)) {
         $this->log->error('No admin email configured.', $settings['mailTo']);
         return;
     }
     $this->log->dev('Send admin notification mail.');
     /* @var $post Post */
     $post = $comment->getPost();
     $subject = $this->translate('subject.admin.newSubscription', $post->getTitle());
     $variables = array('post' => $post, 'comment' => $comment, 'subject' => $subject);
     $emailBody = $this->emailService->render($variables, $emailTemplate);
     $this->emailService->send(array($settings['mailTo']['email'] => $settings['mailTo']['name']), array($settings['mailFrom']['email'] => $settings['mailFrom']['name']), $subject, $emailBody);
 }
Beispiel #3
0
 /**
  * Write session data
  */
 private function writeToSession($key, $data)
 {
     $this->log->dev('Write so FE session', $data);
     $this->frontendUser->setKey('ses', 'tx_t3extblog_' . $key, $data);
     $this->frontendUser->storeSessionData();
 }