2 namespace TYPO3\CMS\Form\PostProcess;
122 $this->formUtility = FormUtility::create($this->controllerContext->getConfiguration());
146 if (isset($this->typoScript[
'subject'])) {
147 $subject = $this->formUtility->renderItem(
148 $this->typoScript[
'subject.'],
149 $this->typoScript[
'subject']
158 $this->mailMessage->setSubject($subject);
170 if (isset($this->typoScript[
'senderEmail'])) {
171 $fromEmail = $this->formUtility->renderItem(
172 $this->typoScript[
'senderEmail.'],
173 $this->typoScript[
'senderEmail']
178 $fromEmail =
$GLOBALS[
'TYPO3_CONF_VARS'][
'MAIL'][
'defaultMailFromAddress'];
183 if (isset($this->typoScript[
'senderName'])) {
184 $fromName = $this->formUtility->renderItem(
185 $this->typoScript[
'senderName.'],
186 $this->typoScript[
'senderName']
191 $fromName =
$GLOBALS[
'TYPO3_CONF_VARS'][
'MAIL'][
'defaultMailFromName'];
194 if (!empty($fromName)) {
195 $from = array($fromEmail => $fromName);
199 $this->mailMessage->setFrom($from);
208 protected function filterValidEmails($emails)
210 if (!is_string($emails)) {
217 $addresses = $addressParser->parseAddressList();
219 $validEmails = array();
220 foreach ($addresses as $address) {
221 $fullAddress = $address->mailbox .
'@' . $address->host;
223 if ($address->personal) {
224 $validEmails[$fullAddress] = $address->personal;
226 $validEmails[] = $fullAddress;
242 $emails = $this->formUtility->renderItem(
243 $this->typoScript[
'recipientEmail.'],
244 $this->typoScript[
'recipientEmail']
246 $validEmails = $this->filterValidEmails($emails);
247 if (!empty($validEmails)) {
248 $this->mailMessage->setTo($validEmails);
261 $emails = $this->formUtility->renderItem(
262 $this->typoScript[
'ccEmail.'],
263 $this->typoScript[
'ccEmail']
265 $validEmails = $this->filterValidEmails($emails);
266 if (!empty($validEmails)) {
267 $this->mailMessage->setCc($validEmails);
280 if (isset($this->typoScript[
'replyToEmail'])) {
281 $emails = $this->formUtility->renderItem(
282 $this->typoScript[
'replyToEmail.'],
283 $this->typoScript[
'replyToEmail']
288 $validEmails = $this->filterValidEmails($emails);
289 if (!empty($validEmails)) {
290 $this->mailMessage->setReplyTo($validEmails);
305 if (isset($this->typoScript[
'priority'])) {
306 $priorityFromTs = $this->formUtility->renderItem(
307 $this->typoScript[
'priority.'],
308 $this->typoScript[
'priority']
311 if (!empty($priorityFromTs)) {
314 $this->mailMessage->setPriority($priority);
326 if (isset($this->typoScript[
'organization'])) {
327 $organization = $this->formUtility->renderItem(
328 $this->typoScript[
'organization.'],
329 $this->typoScript[
'organization']
332 if (!empty($organization)) {
334 $this->mailMessage->getHeaders()->addTextHeader(
'Organization', $organization);
348 $characterSet = null;
349 if (
$GLOBALS[
'TSFE']->config[
'config'][
'formMailCharset']) {
350 $characterSet =
$GLOBALS[
'TSFE']->csConvObj->parse_charset(
$GLOBALS[
'TSFE']->config[
'config'][
'formMailCharset']);
352 $characterSet =
$GLOBALS[
'TSFE']->metaCharset;
355 $this->mailMessage->setCharset($characterSet);
368 $htmlContent = $this->getView($this->htmlMailTemplatePath)->render();
369 $this->mailMessage->setBody($htmlContent,
'text/html');
381 $plainContent = $this->getView($this->plaintextMailTemplatePath,
'Plain')->render();
382 $this->mailMessage->addPart($plainContent,
'text/plain');
393 if ($this->mailMessage->getTo() && $this->mailMessage->getBody()) {
394 $this->mailMessage->send();
405 if ($this->mailMessage->isSent()) {
421 $pattern =
'/[\\r\\n\\f\\e]/';
422 if (preg_match($pattern, $string) > 0) {
423 $this->dirtyHeaders[] = $string;
437 $sessionData = $this->sessionUtility->getSessionData();
438 if (is_array($sessionData)) {
439 foreach ($sessionData as $fieldName => $values) {
440 if (is_array($values)) {
441 foreach ($values as $file) {
442 if (isset($file[
'tempFilename'])) {
444 is_file($file[
'tempFilename'])
464 isset($this->typoScript[
'htmlMailTemplatePath'])
465 && $this->typoScript[
'htmlMailTemplatePath'] !==
''
467 $this->htmlMailTemplatePath = $this->typoScript[
'htmlMailTemplatePath'];
471 isset($this->typoScript[
'plaintextMailTemplatePath'])
472 && $this->typoScript[
'plaintextMailTemplatePath'] !==
''
474 $this->plaintextMailTemplatePath = $this->typoScript[
'plaintextMailTemplatePath'];
485 protected function getView($templateName, $scope =
'Html')
487 $configurationManager = $this->objectManager->get(\TYPO3\CMS\Extbase\Configuration\ConfigurationManager::class);
488 $typoScript = $configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
490 $view = $this->objectManager->get(\TYPO3\CMS\Fluid\View\StandaloneView::class);
493 'templateRootPaths' =>
$typoScript[
'view'][
'templateRootPaths'],
494 'partialRootPaths' =>
$typoScript[
'view'][
'partialRootPaths'],
497 foreach (
$typoScript[
'view'][
'templateRootPaths'] as &$path) {
498 if (substr($path, -1) !==
'/') {
501 $path .=
'PostProcessor/Mail/' . $this->controllerContext->getConfiguration()->getThemeName();
504 foreach (
$typoScript[
'view'][
'partialRootPaths'] as &$path) {
505 if (substr($path, -1) !==
'/') {
508 $path .= $this->controllerContext->getConfiguration()->getThemeName() .
'/PostProcessor/Mail/' . $scope .
'/';
510 $view->setLayoutRootPaths(
$typoScript[
'view'][
'layoutRootPaths']);
511 $view->setTemplateRootPaths(
$typoScript[
'view'][
'templateRootPaths']);
512 $view->setPartialRootPaths(
$typoScript[
'view'][
'partialRootPaths']);
513 $view->setTemplate($templateName);
514 $view->assignMultiple(array(
515 'model' => $this->form
528 return $this->formUtility->renderItem(
529 $this->typoScript[
'messages.'][$messageType .
'.'],
530 $this->typoScript[
'messages.'][$messageType],
544 $label = static::LOCALISATION_OBJECT_NAME .
'.' . $type;
558 if (empty($this->typoScript[$propertyName])) {
562 $propertyValue = $this->typoScript[$propertyName];
563 $incomingData = $this->controllerContext->getValidationElement();
564 if (!$incomingData->hasIncomingField($propertyValue)) {
568 return $incomingData->getIncomingField($propertyValue);