Make email templates configurable in TypoScript
I wanted to edit the email templates for the user registration as they're only in English... At first I wondered why my template was not used although laying in a folder called "Email" in the same path as the frontend ones. Then I digged deeper into the TYPO3 mail API and found one had to override or extend the path of e.g. $GLOBALS['TYPO3_CONF_VARS']['MAIL']['templateRootPaths'][300]
in the localconf.php of my sitepackage. As this is fluid I first had to check which array key used by EXT:modules to do so (it's 1659186453
) to be sure my template would override yours. No problem at all but a little elaborate overall.
I later discovered the way EXT:felogin is doing it for the password recovery mail as I had to edit this one too. There you can define the template path (and so on) in TypoScript rather than in the localconf.php. And these settings are merged into the MAIL settings in the function getMailTemplatePaths of class TYPO3\CMS\FrontendLogin\Configuration\RecoveryConfiguration. Maybe you could consider doing something similar. At best with a fallback solution to your paths, so you don't have to overwrite all templates (in felogin only one is set, but there's also only one template...).
EXT:modules version tested 5.7.1 on TYPO3 v10.4.37 but should be also valid for the master.
Ich wollte die E-Mail-Templates für die Benutzerregistrierung bearbeiten, da sie nur auf Englisch sind... Zuerst habe ich mich gewundert, warum meine Vorlage nicht verwendet wurde, obwohl sie in einem Ordner namens "Email" im gleichen Pfad wie die Frontend-Vorlagen lag. Dann habe ich mich tiefer in die TYPO3 Mail API eingearbeitet und herausgefunden, dass ich den Pfad von z.B. $GLOBALS['TYPO3_CONF_VARS']['MAIL']['templateRootPaths'][300]
in der localconf.php meines Sitepackage überschreiben bzw. erweitern muss. Da es Fluid ist, musste ich zuerst prüfen, welcher Array-Schlüssel von EXT:modules dafür verwendet wird (es ist 1659186453
), um sicher zu sein, dass meine Vorlage die originale überschreibt. Das war kein Problem, aber ein wenig aufwändig insgesamt.
Später habe ich herausgefunden, wie es EXT:felogin für die Passwort-Wiederherstellungs-Mail macht, da ich diese auch bearbeiten musste. Dort kann man den Pfad zum Template usw. in TypoScript und nicht in der localconf.php festlegen. Und diese Einstellungen werden in der Funktion getMailTemplatePaths der Klasse TYPO3\CMS\FrontendLogin\Configuration\RecoveryConfiguration in die MAIL-Einstellungen gemerged. Vielleicht könntet ihr etwas Ähnliches in Erwägung ziehen. Am besten mit einer Fallback-Lösung auf eure Pfade, damit man nicht alle Templates überschreiben muss (bei felogin wird nur einer gesetzt, dort gibt's aber auch nur ein Template...).
EXT:modules Version getestet 5.7.1 auf TYPO3 v10.4.37, sollte aber auch für den Master gelten.