5

I know I can set the template in the email settings to use a HTML template but how do I pass the content of the system messages (activate your account, reset your password, etc) to this template?

I've added this to the html template but then the email that is sent is blank:

{% block content %}
{% endblock %}
Niall Thompson
  • 1,199
  • 1
  • 11
  • 24

1 Answers1

14

EmailService->sendEmailByKey() sets the htmlBody property of EmailModel to this:

$emailModel->htmlBody = "{% extends '{$template}' %}\n".
    "{% set body %}\n".
        $emailModel->htmlBody.
    "{% endset %}\n";

So if you've got a custom email template in craft/templates/email.html, in the control panel under Settings → Email → HTML Email Template, you'd set the value to email.html.

And you'd simply output the dynamic email content in your template by using {{ body }} like so:

<html>
    <body>
        <div>
            {{ body }}
        </div>
    </body>
</html>
Brad Bell
  • 67,440
  • 6
  • 73
  • 143