By Patrick Jackson on Saturday, 20 February 2021
Category: February

Joomla 4: HTML Email templating

Continuing our series introducing new features you’ll find in Joomla 4, this month we look at the improved email template system that allows you to override system email messages, as well as creating HTML templates on your site.

In the past, you needed to modify system emails in Joomla 3 by creating a custom language override, and were limited to having the emails going out as plain text unless you installed an extension to manage the messaging.

In Joomla 4, the new Mail Templates component allows you to more easily update your system email messages, and also adds HTML formatting to allow you to make your emails look far more professional and attention grabbing.

You can access the new Mail Templates component as a Super Administrator by going to System > Mail Templates when logged into the Joomla 4 administrator dashboard.

At the time of writing, Joomla 4 has 25 Mail Templates that you can customize by editing the wording, look, feel, translation and formatting to suit your site’s needs. Personally I’d not worry much about modifying ones only for administrators, such as the User Actions Log email, and concentrate more on branding emails that customers will receive when interacting with your website.

Obviously, in a magazine article we can’t cover all 25, so I’m going to cover the basic functionality of the component, and you can experiment with it more when configuring your Joomla 4 site. For detailed information on using the Mail Templates component, see the Documentation section in the Further Reading at the end of this article.

Planning

Typically the HTML emails will all follow the same pattern - an email template that might have your company logo, background formatting and contact information, all laid out with an area for the content to be inserted.

Unfortunately, not all email browsers treat HTML the same way, and so as you build your base template, take the time to know what will and won’t work. According to Litmus Email Analytics in January 2021, here’s some things to consider in your design process:

Litmus have an excellent step by step guide on coding responsive emails from scratch. You can also use the functionality of extensions like Acymailing, or third party email services like MailChimp to create your own custom template, and export it to then use in the Joomla 4 Mail Templates component.

Once you have a HTML template worked out, you can then add the general template into the HTML Body in the template and then copy the body text from the plain text email into the content area of your HTML template.

Modifying templates

When you first open the Mail Templates component, you’ll see that there’s a few things to note:

Next, click on the title of an existing template to open the editor.

You’ll initially see language strings displayed. These are the default email strings, with there being one for the subject line, and another for the body text of the email.

Clicking on the Edit Subject switch or the Edit Body switch will convert the locked field showing the language string into the value of the language string. From there you can customise the text that is shown in the field.

Scrolling down the page, you then click the Edit HTML Body switch in order to activate the HTML editor for the template.

If you’ve got your own template ready, you can switch the editor to HTML view and paste in your code first, before switching back to the HTML editor. You would then copy the default text from the plain text version and paste it into the content area on your HTML template.

You’ll see a number of tags in the default text, as well as shown below the Edit HTML Body switch. These will be replaced when the email is sent with values created by the component triggering the email.

After you’re happy with your changes, click Save and Close, and you’re mail template changes will be active.

From there, test the new template by triggering the selected email through the function it applies to, and then adjust further as needed.

Multi-Language Templates

Before you can create templates for other languages, you’ll first need to install additional language packs for Joomla 4. You would then repeat the same process for each language’s mail templates.

We’ll be covering more on translation and localisation in an upcoming edition of Joomla Community Magazine, so be sure to subscribe to the magazine newsletter to be sure to know when the next edition of the magazine has been published.

Further Reading

Blogs

A number of Joomla blogs covered how to use the new HTML Mail Templates at the end of 2020:

The Joomla Documentation team is always ready to welcome new contributors to improve and translate documentation. The Mail Template help pages at the moment are among those needing more local translations. You can get started contributing to Joomla’s documentation here.

Email Creation Resources

Email Testing Tools

When you have issues with email deliverability, MX Toolbox gives you a range of tools to check everything from your MX, A and SPF records through to checking if your mail server has been blacklisted due to spam.

If you have more email creation resources, please share them in the comments below. I look forward to seeing the exciting range of HTML Email Templates people implement for Joomla 4.

Leave Comments