Review main Merged

92483[FEATURE] Introduce TemplatedEmailFactory for centralized email creation

Benni Mack CR +2 V +2 Expert +1184 −402 updated 07/09/26, 08:48

Commit message

A new TemplatedEmailFactory class provides centralized creation of
FluidEmail instances with three methods for different use cases:

- create(): For backend/CLI contexts using global configuration

- createFromRequest(): For frontend contexts with site-specific
  template paths merged from site settings

- createWithOverrides(): For extensions needing custom template
  paths merged with global configuration, and site settings if
  available

A new site set "typo3/email" in EXT:core defines settings for
email.templateRootPaths, email.layoutRootPaths, email.partialRootPaths,
and email.format that can be configured per site.

All existing FluidEmail usages in core have been migrated to use
the new factory, in order to reduce direct dependencies to the
implementation for future optimizations.

Review

  • Code review CR +2 Done
    • Georg Ringer +2
    • Garvin Hicking +1
  • Verified V +2 Done
    • Georg Ringer +2
    • Garvin Hicking +1
    • core-ci +1 CI

Issues 1

Files 33

Show 13 more files

Review log 3549

Show 1724 earlier messages
  1. Benni Mack uploaded patch set 1 01/23/26, 14:58

  2. Benni Mack uploaded patch set 2 01/23/26, 15:01

  3. core-ci voted on patch set 1 V -1 01/23/26, 15:12 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/94180

  4. core-ci voted on patch set 2 V -1 01/23/26, 15:14 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/94181

  5. Simon Schaufelberger uploaded patch set 3 V -1 02/04/26, 15:12

  6. core-ci voted on patch set 3 V -1 02/04/26, 15:50 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95051

  7. Simon Schaufelberger uploaded patch set 4 V -1 02/04/26, 16:37

  8. core-ci voted on patch set 4 V -1 02/04/26, 16:51 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95071

  9. core-ci commented on patch set 4 02/04/26, 17:13 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95071

  10. Simon Schaufelberger uploaded patch set 5 V -1 02/04/26, 23:34

  11. core-ci voted on patch set 5 V +1 02/04/26, 23:43 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95085

  12. Simon Schaufelberger voted on patch set 5 CR +1 V +1 02/05/26, 08:57

  13. Benni Mack marked it ready for review 02/05/26, 09:16

  14. Matthias Vogel commented on patch set 5 02/05/26, 10:01

    FailedMfaAttemptNotification.php:51

    @benni@typo3.org why do we not use GeneralUtility::validEmail function anymore?
  15. Benni Mack commented on patch set 5 02/05/26, 10:27

    FailedMfaAttemptNotification.php:51 Reply

    oh good point, that was for testing purposes back then...
  16. Simon Praetorius commented on patch set 5 02/05/26, 11:30

    Can we deprecate the direct usage of `new FluidEmail` then, e. g. by marking the constructor as `@internal`?
  17. Simon Schaufelberger commented on patch set 5 02/05/26, 11:52

    Reply

    I would not do it in this patch but would do a separate patch instead.
  18. Simon Praetorius commented on patch set 5 02/05/26, 12:29

    TemplatedEmailFactory.php:34

    intentionally not final?

    TemplatedEmailFactory.php:101

    ```suggestion * will take precedence, while existing numeric keys will be overwritten. ```

    TemplatedEmailFactory.php:103

    `string[]` as type annotation

    Feature-91724-TemplatedEmailFactory.rst:177

    ```suggestion Extensions that send emails are encouraged to use the :php:`TemplatedEmailFactory` to create ``` ?
  19. Simon Praetorius commented on patch set 5 02/05/26, 12:30

    Reply

    Just want to make sure that this is the next step (still in v14) before we merge this.
  20. Matthias Vogel uploaded patch set 6 CR +1 V +1 02/05/26, 15:22

  21. Matthias Vogel commented on patch set 6 02/05/26, 15:22

    FailedMfaAttemptNotification.php:51 Reply

    Done

    TemplatedEmailFactory.php:34 Reply

    I Think this is ok, so you can XCLASS here. Otherwise we should add an interface.

    TemplatedEmailFactory.php:101 Reply

    Done

    TemplatedEmailFactory.php:103 Reply

    Done

    Feature-91724-TemplatedEmailFactory.rst:177 Reply

    Done
  22. Matthias Vogel commented on patch set 6 02/05/26, 15:22

    Reply

    Done
  23. Simon Schaufelberger voted on patch set 6 CR +1 V +1 02/05/26, 15:27

  24. core-ci voted on patch set 6 V +1 02/05/26, 15:32 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95172

  1. Simon Praetorius commented on patch set 6 02/05/26, 21:32

    TemplatedEmailFactory.php:114

    When testing this, I found it a bit confusing that the paths and the format entered in site settings are only used "sometimes", even though there is clearly a site context. For example, for EXT:form finishers they don't work. I understand that the whole merging can get complicated and could also introduce breaking changes, but it is confusing when you enter something as advertised and it gets ignored.
  2. Simon Schaufelberger commented on patch set 6 CR 0 V -1 02/06/26, 09:15

    On it

    TemplatedEmailFactory.php:114 Reply

    Thanks for testing. On it.
  3. Benni Mack uploaded patch set 7 V +1 02/18/26, 21:53

  4. core-ci voted on patch set 7 V -1 02/18/26, 22:10 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/96195

  5. Benni Mack uploaded patch set 8 V -1 02/19/26, 15:15

  6. core-ci voted on patch set 8 V +1 02/19/26, 15:23 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/96262

  7. Garvin Hicking commented on patch set 8 02/19/26, 23:12

    TemplatedEmailFactory.php:114 Reply

    But in this case if a consumer like EXT:form is thehigjer order" consumer, that specific config must have priority over the site config IMO. The highest soecificity would win, for me this is an exlected outcome. I want to be abke to style the form finisher mails differently than my "usual" other mails. Otherwise I would need to remove the form mail template configs so the override order can fallback to site request context?

    settings.definitions.yaml:3

    we need to use a labels.xlf file so these settings can be translated as others like ext:seo, felogin and the others Btw, reading this: we could offer a site set definition also for email sender name / address configuration, and logo:assets? This would make fluidmails to be site-specific finally....

    Feature-91724-TemplatedEmailFactory.rst:32

    This is unclear to me, is it: Site settings ?? Overrides ?? Global Overrides ?? Site Settings ?? Global Overrides ?? Global ?? Site Settings Maybe a clear order with arrows is clearer than "on top of ... before".

    Feature-91724-TemplatedEmailFactory.rst:160

    Better use DI to not make people believe they need to use it like this when "createWithOverride" is involved

    Feature-91724-TemplatedEmailFactory.rst:211

    Oh here it is. Link to that from the top, or copy? Also maybe "(when a site and the set dependency is available)" for clarity that the dependency must be selected for a site?

    SystemStatusUpdateTask.php:104

    ```suggestion // @todo DI should be used to inject the MailerInterface in v15.0 ```

    SystemStatusUpdateTask.php:116

    ```suggestion // @todo DI should be used to inject the MailerInterface in v15.0 ```
  8. Simon Praetorius commented on patch set 8 02/20/26, 15:53

    TemplatedEmailFactory.php:114 Reply

    That should still be possible via the paths specified in form config (yaml) if I understand the overriding chain correctly. However, the `format` option might be problematic because it can't be merged. Maybe the format needs to be part of the API as well to be able to set it? Maybe even establish a DTO for the overrides, similarly to `ViewFactoryData`?
  9. Benni Mack commented on patch set 8 02/27/26, 15:04

    TemplatedEmailFactory.php:114 Reply

    Coming from a practical PoV: Format is always overridden, (= null -> use default, otherwise: html, text or both), but cannot be merged.
  10. Garvin Hicking uploaded patch set 9 V +1 03/13/26, 06:41

    address merge conflict
  11. core-ci voted on patch set 9 V +1 03/13/26, 06:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/97870

  12. Garvin Hicking uploaded patch set 10 V +1 03/13/26, 08:16

    Adjust ReST file
  13. core-ci voted on patch set 10 V +1 03/13/26, 08:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/97873

  14. Garvin Hicking commented on patch set 10 03/13/26, 12:14

    TemplatedEmailFactory.php:114 Reply

    The problem here is/was that Site settings transfer a "stringlist" as a "list" (numerical indexes from 0..X) I believe. I'll address this in a patch. About "format" I agree with Benni, this can only be either authoritative (wins, when set in site settings) or implicative, but not mergeable. Listeners to BeforeMailerSentMessageEvent however could set the format as a last-resort basis.

    settings.definitions.yaml:3 Reply

    Adjusted within the patch. Adding further config options should must be done in a follow-up.

    Feature-91724-TemplatedEmailFactory.rst:32 Reply

    Reworded this.

    Feature-91724-TemplatedEmailFactory.rst:160 Reply

    I see this now, it's because of AbstractTask. I've changed it.

    Feature-91724-TemplatedEmailFactory.rst:211 Reply

    Adjusted.

    SystemStatusUpdateTask.php:104 Reply

    Done

    SystemStatusUpdateTask.php:116 Reply

    Done
  15. Garvin Hicking uploaded patch set 11 V +1 03/13/26, 12:16

    Fix Site Settings Gui assignment
  16. Garvin Hicking uploaded patch set 12 03/13/26, 12:45

    fix tests
  17. core-ci voted on patch set 11 V -1 03/13/26, 12:46 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/97889

  18. core-ci voted on patch set 12 V +1 03/13/26, 12:54 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/97894

  19. Garvin Hicking commented on patch set 12 CR +1 V +1 03/13/26, 13:07

    I've spent the better of my day on this and changed some tests, mainly because using the Site Settings GUI did not provide the expected results. For this I now do a "different" array merge strategy which I think should do "the trick". Happy for feedback. We should get this in.
  20. Garvin Hicking commented on patch set 13 CR +1 V +1 03/13/26, 13:17

    Published edit on patch set 12.
  21. Garvin Hicking voted on patch set 13 CR +1 V +1 03/13/26, 13:17

  22. core-ci voted on patch set 13 V +1 03/13/26, 13:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/97899

  23. Georg Ringer voted on patch set 13 CR +2 V +2 03/13/26, 15:25

  24. Georg Ringer merged patch set 14 03/13/26, 15:25

  25. Lina Wolf commented on patch set 14 05/25/26, 13:05

    Reply Unresolved

    So if the constructor is internal and therefore deprecated, shouldnt it be mentioned in the changelog?