HTML customization for certain emails

All emails sent from your site will be wrapped in the email template that’s set on your Customize / Email Style / HTML Template section. The only exception to this that I’m aware of is that you can deselect the apply custom styles to digest site setting so that summary emails do not use the custom email template.

It is possible to add HTML to email templates for specific email types. This is done in the Customize / Email section of your site. These templates will be wrapped in the email template that is set in your Customize / Email Style / HTML Template section.

You can only add HTML to these templates that will not get stripped out by Discourse when the template is saved.

To test out this functionality, I set the User Posted email template on my development site to:

<div data-user-posted>
%{header_instructions}

%{message}

%{context}

%{respond_instructions}
</div>

I then added the following CSS rule to the CSS tab of my Customize / Email Style page:

[data-user-posted] {
    color: #ffffff;
    background: #000000;
}

The CSS gets added as inline styles to the div and is displayed correctly in the email.

One thing to keep in mind with any customizations you make to emails is that the display of emails is dependent on the client that the email is viewed on. If you are making complex changes, it would be good to test them on a few popular email clients so that you know how they will be displayed.