Пример #1
0
 public function render()
 {
     if ($this->mailMessage->isSent()) {
         $output = $this->success();
     } else {
         $output = $this->error();
     }
     return $output;
 }
Пример #2
0
 /**
  * Sends an e-mail, if sender and recipient is an valid e-mail address
  *
  * @param string $sender The sender
  * @param string $recipient The recipient
  * @param string $subject The subject
  * @param string $body E-Mail body
  * @param string $name Optional sendername
  *
  * @return bool true/false if message is sent
  */
 public function sendEmailMessage($sender, $recipient, $subject, $body, $name)
 {
     if (GeneralUtility::validEmail($sender) && GeneralUtility::validEmail($recipient)) {
         $this->mail->setFrom($sender, $name);
         $this->mail->setSubject($subject);
         $this->mail->setBody($body, 'text/html');
         $this->mail->setTo($recipient);
         $this->mail->send();
         return $this->mail->isSent();
     } else {
         return false;
     }
 }
Пример #3
0
 /**
  * Sends an e-mail, if sender and recipient is an valid e-mail address
  *
  * @param string $sender The sender
  * @param string $recipient The recipient
  * @param string $subject The subject
  * @param string $body E-Mail body
  * @param string $name Optional sendername
  * @param array $attachments Array of files (e.g. ['/absolute/path/doc.pdf'])
  *
  * @return bool TRUE/FALSE if message is sent
  */
 public function sendEmailMessage($sender, $recipient, $subject, $body, $name = null, $attachments = [])
 {
     if (GeneralUtility::validEmail($sender) && GeneralUtility::validEmail($recipient)) {
         $this->initialize();
         $this->mailer->setFrom($sender, $name);
         $this->mailer->setSubject($subject);
         $this->mailer->setBody($body, 'text/html');
         $this->mailer->setTo($recipient);
         $this->addAttachments($attachments);
         $this->mailer->send();
         return $this->mailer->isSent();
     } else {
         return false;
     }
 }
Пример #4
0
 /**
  * Render the message after trying to send the mail
  *
  * @return string HTML message from the mail view
  */
 protected function render()
 {
     if ($this->mailMessage->isSent()) {
         $output = $this->renderMessage('success');
     } else {
         $output = $this->renderMessage('error');
     }
     return $output;
 }
 /**
  * Sends the actual mail and handles autorespond message
  *
  * @return bool
  */
 public function sendTheMail()
 {
     // Sending the mail requires the recipient and message to be set.
     if (!$this->mailMessage->getTo() || !trim($this->mailMessage->getBody())) {
         return FALSE;
     }
     $this->mailMessage->send();
     // Auto response
     if ($this->autoRespondMessage) {
         $theParts = explode('/', $this->autoRespondMessage, 2);
         $theParts[0] = str_replace('###SUBJECT###', $this->subject, $theParts[0]);
         $theParts[1] = str_replace(array('/', '###MESSAGE###'), array(LF, $this->plainContent), $theParts[1]);
         /** @var $autoRespondMail \TYPO3\CMS\Core\Mail\MailMessage */
         $autoRespondMail = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Mail\MailMessage::class);
         $autoRespondMail->setTo($this->fromAddress)->setSubject($theParts[0])->setFrom($this->recipient)->setBody($theParts[1]);
         $autoRespondMail->send();
     }
     return $this->mailMessage->isSent();
 }
Пример #6
0
 /**
  * @param MailMessage $message
  * @throws \UnexpectedValueException
  * @throws \BadFunctionCallException
  */
 public function log(MailMessage $message)
 {
     $tableName = ExtensionManagementUtility::isLoaded('messenger') ? 'tx_messenger_domain_model_sentmessage' : 'tx_formule_domain_model_sentmessage';
     $values = ['pid' => (int) $this->getFrontendObject()->id, 'sender' => $this->formatEmails($message->getFrom()), 'recipient' => $this->formatEmails($message->getTo()), 'recipient_cc' => $this->formatEmails($message->getCc()), 'recipient_bcc' => $this->formatEmails($message->getBcc()), 'subject' => $this->getDatabaseConnection()->quoteStr($message->getSubject(), $tableName), 'body' => $this->getDatabaseConnection()->quoteStr($message->getBody(), $tableName), 'context' => (string) GeneralUtility::getApplicationContext(), 'is_sent' => (int) $message->isSent(), 'sent_time' => time(), 'ip' => GeneralUtility::getIndpEnv('REMOTE_ADDR'), 'crdate' => time()];
     $this->getDatabaseConnection()->exec_INSERTquery($tableName, $values);
 }