TemplatedEmailFactory

Read onlyYes

Factory for creating FluidEmail instances.

Provides three creation methods:

  • create(): For backend/CLI usage with global configuration only
  • createFromRequest(): For frontend usage with site-aware template paths
  • createWithOverrides(): For extensions needing custom template path overrides
Attributes
#[Autoconfigure]
$public: true

Table of Contents

Methods

create()  : FluidEmail
Create a FluidEmail instance using global configuration only.
createFromRequest()  : FluidEmail
Create a FluidEmail instance with template paths resolved from site settings.
createWithOverrides()  : FluidEmail
Create a FluidEmail instance with custom template path overrides.

Methods

create()

Create a FluidEmail instance using global configuration only.

public create([ServerRequestInterface|null $request = null ]) : FluidEmail

Use this method for backend/CLI contexts (e.g., login notifications, scheduler tasks, install tool) where no site context is available or site-specific templates are not desired.

Template paths are read from $GLOBALS['TYPO3_CONF_VARS']['MAIL'].

Parameters
$request : ServerRequestInterface|null = null
Return values
FluidEmail

createFromRequest()

Create a FluidEmail instance with template paths resolved from site settings.

public createFromRequest(ServerRequestInterface $request) : FluidEmail

Use this method for frontend contexts (e.g., form submissions, felogin) where site-specific email templates should be applied.

The factory extracts the site from the request attribute and merges site-specific email settings with global mail configuration.

Site settings used:

  • email.templateRootPaths: array of template root paths
  • email.layoutRootPaths: array of layout root paths
  • email.partialRootPaths: array of partial root paths
  • email.format: email format (html, plain, both)
Parameters
$request : ServerRequestInterface
Return values
FluidEmail

createWithOverrides()

Create a FluidEmail instance with custom template path overrides.

public createWithOverrides([array<string|int, string> $templateRootPaths = [] ][, array<string|int, string> $layoutRootPaths = [] ][, array<string|int, string> $partialRootPaths = [] ][, ServerRequestInterface|null $request = null ]) : FluidEmail

Use this method when extensions need to provide their own template paths that are merged on top of the base configuration. The base configuration is built from global $GLOBALS['TYPO3_CONF_VARS']['MAIL'] with site settings merged on top when a request with a site attribute is provided.

The override paths are then merged using array_replace(), so higher numeric keys in overrides will take precedence, while existing numeric keys will be overwritten.

Parameters
$templateRootPaths : array<string|int, string> = []

Additional template root paths to merge

$layoutRootPaths : array<string|int, string> = []

Additional layout root paths to merge

$partialRootPaths : array<string|int, string> = []

Additional partial root paths to merge

$request : ServerRequestInterface|null = null

Optional request for site resolution and ViewHelper context

Return values
FluidEmail

        
On this page

Search results