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
No edit summary
m (Couple of typos)
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Template:Themes}}
{{Template:Themes}}
 
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.
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.  
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.  
Line 11: Line 10:
https://tracker.moodle.org/browse/MDL-52990
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 you 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.
Adding css and layout to emails can be fairly complex so be sure to test in all the email clients your audience will use in the same way you 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 ==
== Examples / recipes ==
Creating a theme for a client who wants to flag all emails as unclassified
Creating a theme for a client who wants to flag all emails as unclassified


/theme/military/templates/email_subject.mustache
/theme/military/templates/email_subject.mustache
 
<syntaxhighlight lang="php">
<code php>
{{{subject}}} [SEC=UNCLASSIFIED]
{{{subject}}} [SEC=UNCLASSIFIED]
</code>
</syntaxhighlight>

Revision as of 07:31, 5 April 2022

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 your audience will use in the same way you 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]