Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Themed emails: Difference between revisions

From MoodleDocs
m (Text replacement - "<code php>" to "<syntaxhighlight lang="php">")
m (Text replacement - "</code>" to "</syntaxhighlight>")
Line 21: Line 21:
<syntaxhighlight lang="php">
<syntaxhighlight lang="php">
{{{subject}}} [SEC=UNCLASSIFIED]
{{{subject}}} [SEC=UNCLASSIFIED]
</code>
</syntaxhighlight>

Revision as of 20:23, 14 July 2021


Emails are an important and often neglected component when it comes to branding and theming, and in most cases an email is the very first impression a user will get. For example a user might have been batch uploaded and sent an email by moodle, or they may have used the email self registration plugin and they must interact with an email before they can really interact with moodle.

Branding all of your moodle emails is quite simple and handled via Templates the same as other normal theme components. This give you the ability to add fixed headers and footers to the email body, as well as string prefix / suffix to the email subject, and the From name.

https://github.com/moodle/moodle/blob/master/lib/templates/email_subject.mustache

For more example and background see also:

https://tracker.moodle.org/browse/MDL-52990

Adding css and layout to emails can be fairly complex so be sure to test in all the email clients you audience will use in the same way your should test across browsers. Note that you should probably not attempt to reference the css from your moodle theme directly and will need to write inline css specifically targeting email.

Examples / recipes

Creating a theme for a client who wants to flag all emails as unclassified

/theme/military/templates/email_subject.mustache

{{{subject}}} [SEC=UNCLASSIFIED]