Managing Mail Template Layout
From Joomla! Documentation
Introduction[edit]
The Mail Template Layout feature, introduced in Joomla 5.2, provides new capabilities for managing email templates by allowing custom mail template layouts. This feature supports the creation of a parent wrapper around existing mail templates and introduces responsive mail layouts, making it easier to manage the presentation of outgoing emails.
Key Features[edit]
- A new default responsive mail template layout file, `mailtemplate.php`, which renders email content with the site name in the footer and an optional logo.
- A new form field, `MailtemplateLayoutField`, that lists available mail template layouts (overrides) from frontend templates.
- Updates to the `MailTemplate` class to handle layout data and render email content using the specified layout.
- Global configuration options to enable or disable HTML layout and select a mail template layout.
- Template-specific configuration options to disable HTML layout and select a mail template layout for each template individually.
- Template model adjustments to remove HTML layout fields when mail style is set to plaintext.
Instructions[edit]
To configure and test the Mail Template Layout feature, follow these steps:
- Go to Global Configuration -> Mail Templates.
- Set Mail Format to HTML.
- Adjust the global mail templates configuration as needed.
Managing Mail Template Overrides[edit]
This feature also allows you to create mail template overrides within your templates. By creating overrides, you can customize your mail templates without the risk of losing changes during future Joomla updates.
To create a mail template override within a custom template:
- Go to System -> Site Templates -> Open your template (e.g., Cassiopeia).
- In the Create Overrides tab, select joomla -> mail.
- Joomla will copy the `mailtemplate.php` file to your template's `/html/layouts/joomla/mail/` directory, where you can modify it as needed.
Once the override is created, you can adjust the layout and styles of your emails without affecting the base template.
Testing and Configuration[edit]
- Ensure the global mail template settings are configured in the Global Configuration according to your needs.
- If individual template settings are enabled, go to System -> Mail Templates and configure the additional options available.
- Send a test mail to verify that the global or template-specific settings are applied correctly.
Note on the Feature's Origin[edit]
This feature was added in Joomla 5.2 via the improvement introduced in #43829.