Bug #93992

Forms: html emails get sent with plaintext template when using {@format} wildcard in "templatePathAndFilename" and not setting "useFluidEmail"

Added by Denis Mir 6 months ago. Updated 6 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
Start date:
2021-04-27
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.4
Tags:
Complexity:
no-brainer
Is Regression:
Yes
Sprint Focus:

Description

In TYPO3 10LTS (current version 10.4.15) there is a bug in the ext "form" that causes html emails to be sent with the plaintext template.

General setup:

- useFluidEmail: FALSE
- addHtmlPart: TRUE
- templatePathAndFilename: path set including {@format} wildcard

Bug:

With this setup initializeStandaloneView() gets called twice. Once for the plaintext part and once for the html part.

        if (isset($this->options['templatePathAndFilename'])) {
            $this->options['templatePathAndFilename'] = strtr($this->options['templatePathAndFilename'], [
                '{@format}' => $format
            ]);
            $standaloneView->setTemplatePathAndFilename($this->options['templatePathAndFilename']);

This code snippet from line 215 sets $this->options['templatePathAndFilename'] and overrides the {@format} with Plaintext. On the second run (html part) the wildcard is already replaced so the html email gets the same template like the plaintext email.

This is incorrect and a bug.

The error is introduced in 10LTS and was a regression from 9LTS since in 9LTS only a plaintext OR html email could be sent not both.

A simple fix would be:

        if (isset($this->options['templatePathAndFilename'])) {
            $templatePathAndFilename = strtr($this->options['templatePathAndFilename'], [
                '{@format}' => $format,
            ]);
            $standaloneView->setTemplatePathAndFilename($templatePathAndFilename);
        }

Related issues

Has duplicate TYPO3 Core - Bug #90987: EmailFinisher use only plaintext Fluid templateClosed2020-04-09

Actions

Also available in: Atom PDF