/**
  * Sets the sender of the mail message
  *
  * Mostly the sender is a combination of the name and the email address
  *
  * @return void
  */
 protected function setFrom()
 {
     $fromEmail = '';
     if ($this->typoScript['senderEmail']) {
         $fromEmail = $this->typoScript['senderEmail'];
     } elseif ($this->requestHandler->has($this->typoScript['senderEmailField'])) {
         $fromEmail = $this->requestHandler->get($this->typoScript['senderEmailField']);
     } else {
         $fromEmail = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'];
     }
     if (!\TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($fromEmail)) {
         $fromEmail = \TYPO3\CMS\Core\Utility\MailUtility::getSystemFromAddress();
     }
     $fromName = '';
     if ($this->typoScript['senderName']) {
         $fromName = $this->typoScript['senderName'];
     } elseif ($this->requestHandler->has($this->typoScript['senderNameField'])) {
         $fromName = $this->requestHandler->get($this->typoScript['senderNameField']);
     } else {
         $fromName = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName'];
     }
     $fromName = $this->sanitizeHeaderString($fromName);
     if (preg_match('/\\s|,/', $fromName) >= 1) {
         $fromName = '"' . $fromName . '"';
     }
     $from = array($fromEmail => $fromName);
     $this->mailMessage->setFrom($from);
 }
 /**
  * Adds the reply to header of the mail message when configured
  *
  * Checks the address if it is a valid email address
  *
  * @return void
  */
 protected function setReplyTo()
 {
     if (isset($this->typoScript['replyToEmail'])) {
         $emails = $this->typoScript['replyToEmail'];
     } elseif ($this->requestHandler->has($this->typoScript['replyToEmailField'])) {
         $emails = $this->requestHandler->get($this->typoScript['replyToEmailField']);
     }
     $validEmails = $this->filterValidEmails($emails);
     if (!empty($validEmails)) {
         $this->mailMessage->setReplyTo($validEmails);
     }
 }