<p>With @sublymerick's answer as inspiration I define a default html template, <code>_emails/index.twig</code>, passing in the message content that is defined in Craft admin to an html wrapper rather than create separate templates for each.</p>

<pre><code>{% if emailKey is defined and emailKey in [
    'account_activation', 
    'forgot_password', 
    'test_email', 
    'verify_new_email'] 
%}    
    {% include '_emails/templates/basic' with {
        body: body | raw,
    } only %}
{% endif %}
</code></pre>

CC BY-SA 4.0
2020-02-07T11:04:51.733Z
Hi Seth. Could you explain a little bit more what you did? What do you have in _emails/templates/basic ? Thanks.
migmaker
CC BY-SA 4.0
2020-02-07T15:39:33.013Z
_emails/templates/basic is the markup (tables, urgh!) for the email body. So rather than maintaining seperate templates for each message I'd code up the email with everything required (logo, header, footer links, etc) then just pass the message body into that.
Seth Warburton
CC BY-SA 4.0
2020-02-08T09:12:39.513Z
Great thank you ! :)
migmaker
CC BY-SA 4.0
2019-09-04T13:56:10.043Z
2019-09-04T13:56:10.043Z
Seth Warburton
<blockquote>
  <p>I see you can edit the plain text emails at Settings > Email > Messages however I would like to be able to define a twig template to handle creating HTML versions of these.</p>
</blockquote>

<p>Currently not possible natively, but there is a feature request you might want to add a thumbs-up/comment to:</p>

<p><a href="https://github.com/craftcms/cms/issues/1020" rel="nofollow noreferrer">https://github.com/craftcms/cms/issues/1020</a></p>

CC BY-SA 3.0
2017-10-14T02:16:45.273Z
2017-10-14T02:16:45.273Z
Brad Bell
<p>Actually Brad, I was able to figure out a way to do this with some help from @carlcs in the slack channel.</p>

<p>I defined an "HTML Template" in the main email settings screen, then in that template I extend a basic HTML email wrapper, then inside my content block I did this:</p>

<pre><code>{% if emailKey == 'account_activation' %}
    {% include 'mail/activation' %}
{% endif %}
{% if emailKey == 'forgot_password' %}
    {% include 'mail/forgot-password' %}
{% endif %}
{% if emailKey == 'test_email' %}
    {% include 'mail/test-email' %}
{% endif %}
{% if emailKey == 'verify_new_email' %}
    {% include 'mail/verify-new-email' %}
{% endif %}
</code></pre>

<p>Then I just created HTML versions of each email within the context of my wrapper.</p>

<p>It works perfectly!</p>

CC BY-SA 3.0
2017-10-19T16:43:50.373Z
Ahh... clever!!
Brad Bell
CC BY-SA 4.0
2020-02-07T10:57:37.643Z
Hi Rick, could you explain a little bit more what you did? Where is the main email settings screen (Utilities / System messages ?) Thanks.
migmaker
CC BY-SA 4.0
2020-03-09T18:02:09.040Z
@migswd Sorry for the delay. I believe this post was originally made based on Craft2, not Craft3. I don't think there is a spot for that setting in craft3 anymore.
Rick Kukiela
CC BY-SA 3.0
2017-10-19T16:12:49.710Z
2017-10-19T16:12:49.710Z
Rick Kukiela
<p>Just as the title indicates, I'm looking for a way to customize the email template of the "click here to activate your account" email that is sent to users when they register. I would also like to know if its possible and how to do this with other system email templates, such as the reset password link email.</p>

<p>Edit:
I see you can edit the plain text emails at <code>Settings &gt; Email &gt; Messages</code> however I would like to be able to define a twig template to handle creating HTML versions of these.</p>

<plugin-development><emails>
Customize activation and other system emails
# Customize activation and other system emails

(Asked by: username_0 on 2017-10-13)

Just as the title indicates, I'm looking for a way to customize the email template of the "click here to activate your account" email that is sent to users when they register. I would also like to know if its possible and how to do this with other system email templates, such as the reset password link email.

Edit:
I see you can edit the plain text emails at `Settings > Email > Messages` however I would like to be able to define a twig template to handle creating HTML versions of these.

**Tags:** plugin-development, emails


---

## 3 answers

### Answer by username_0 on 2017-10-19. Score: 8 | Accepted answer

Actually Brad, I was able to figure out a way to do this with some help from @carlcs in the slack channel.
I defined an "HTML Template" in the main email settings screen, then in that template I extend a basic HTML email wrapper, then inside my content block I did this:
{% if emailKey == 'account_activation' %}
    {% include 'mail/activation' %}
{% endif %}
{% if emailKey == 'forgot_password' %}
    {% include 'mail/forgot-password' %}
{% endif %}
{% if emailKey == 'test_email' %}
    {% include 'mail/test-email' %}
{% endif %}
{% if emailKey == 'verify_new_email' %}
    {% include 'mail/verify-new-email' %}
{% endif %}

Then I just created HTML versions of each email within the context of my wrapper.
It works perfectly!

> **Comments:**
> **username_3**: Ahh... clever!!  
> **username_2**: Hi Rick, could you explain a little bit more what you did? Where is the main email settings screen (Utilities / System messages ?) Thanks.  
> **username_0**: @migswd Sorry for the delay. I believe this post was originally made based on Craft2, not Craft3. I don't think there is a spot for that setting in craft3 anymore.  

---

### Answer by username_1 on 2019-09-04. Score: 3

With @sublymerick's answer as inspiration I define a default html template, _emails/index.twig, passing in the message content that is defined in Craft admin to an html wrapper rather than create separate templates for each.
{% if emailKey is defined and emailKey in [
    'account_activation', 
    'forgot_password', 
    'test_email', 
    'verify_new_email'] 
%}    
    {% include '_emails/templates/basic' with {
        body: body | raw,
    } only %}
{% endif %}

> **Comments:**
> **username_2**: Hi Seth. Could you explain a little bit more what you did? What do you have in _emails/templates/basic ? Thanks.  
> **username_1**: _emails/templates/basic is the markup (tables, urgh!) for the email body. So rather than maintaining seperate templates for each message I'd code up the email with everything required (logo, header, footer links, etc) then just pass the message body into that.  
> **username_2**: Great thank you ! :)  

---

### Answer by username_3 on 2017-10-14. Score: 1

> I see you can edit the plain text emails at Settings > Email > Messages however I would like to be able to define a twig template to handle creating HTML versions of these.

Currently not possible natively, but there is a feature request you might want to add a thumbs-up/comment to:

<https://github.com/craftcms/cms/issues/1020>


---

