<p>The first part of the <a href="https://craftcms.stackexchange.com/questions/2232/pt-contact-form-plugin-html-email-templates">answer in the post you linked to</a> is wrong in the context of the Contact Form plugin. </p>

<p>Craft only takes the custom "HTML Template Path" email setting into account when <a href="https://craftcms.com/classreference/services/EmailService" rel="nofollow noreferrer">EmailService's</a> <a href="https://craftcms.com/classreference/services/EmailService#sendEmailByKey-detail" rel="nofollow noreferrer">sendEmailByKey</a> is called, which is used for pre-defined Craft emails.</p>

<p>The Contact Form uses <a href="https://craftcms.com/classreference/services/EmailService" rel="nofollow noreferrer">EmailService's</a> <a href="https://craftcms.com/classreference/services/EmailService#sendEmail-detail" rel="nofollow noreferrer">sendEmail</a>, which won't take it into account.</p>

<p>It hasn't been released as part of an official Contact Form plugin release yet so there's no documentation, but thanks to <a href="https://github.com/pixelandtonic/ContactForm/commit/167e830665683deab22026ea3808d00f4b33e107" rel="nofollow noreferrer">this pull request</a>, you've got an <code>onBeforeMessageCompile</code> event that will give a plugin a chance to modify the contents of the email.</p>

CC BY-SA 3.0
2016-07-28T12:51:32.783Z
Thanks for clearing up the confusion. Easiest thing was just adding the template HTML to the email body within ContactFormService.php.
Clive Portman
CC BY-SA 3.0
2016-07-27T16:47:06.470Z
2016-07-27T16:47:06.470Z
2017-04-13T12:51:00.253Z
Brad Bell
<p>For anyone interested, you can use <a href="https://github.com/lukeyouell/craft-contactformtemplates" rel="nofollow noreferrer">Contact Form Templates</a> to make custom email templates in Craft CMS 3.</p>

CC BY-SA 4.0
2019-04-02T09:37:04.303Z
2019-04-02T09:37:04.303Z
JochenM
<p>As Brad points out in his answer, the Contact Form plugin doesn't use the same template. I found the easiest thing to do was replace:</p>

<pre><code>$email-&gt;body      = $message-&gt;message;
</code></pre>

<p>with:</p>

<pre><code>$htmlTemplateTopHalf= &lt;&lt;&lt;TEMPLATETOP
    // insert html here
TEMPLATETOP;

$htmlTemplateBottomHalf= &lt;&lt;&lt;TEMPLATEBOTTOM
    // insert html here
TEMPLATEBOTTOM;

$email-&gt;body      = $htmlTemplateTopHalf;
$email-&gt;body      .= $message-&gt;message;
$email-&gt;body      .= $htmlTemplateBottomHalf;
</code></pre>

CC BY-SA 3.0
2016-07-28T13:01:35.537Z
2016-07-28T13:01:35.537Z
Clive Portman
<p>I could've sworn I've read somewhere on here that the contact form plugin should use the same template as defined in the site's email settings, but it's not working for me.</p>

<p>Does anyone know if the Contact Form plugin supports this (and has it working)?</p>

CC BY-SA 3.0
2016-07-27T13:25:32.947Z
Here's where I saw it: http://craftcms.stackexchange.com/questions/2232/pt-contact-form-plugin-html-email-templates
Clive Portman
<templating><plugin-contactform>
Choose custom email template for Contact Form plugin
# Choose custom email template for Contact Form plugin

(Asked by: username_0 on 2016-07-27)

I could've sworn I've read somewhere on here that the contact form plugin should use the same template as defined in the site's email settings, but it's not working for me.

Does anyone know if the Contact Form plugin supports this (and has it working)?

**Tags:** templating, plugin-contactform
> **Comments:**
> **username_0**: Here's where I saw it: http://craftcms.stackexchange.com/questions/2232/pt-contact-form-plugin-html-email-templates  

---

## 3 answers

### Answer by username_1 on 2016-07-27. Score: 1

The first part of the [answer in the post you linked to](https://craftcms.stackexchange.com/questions/2232/pt-contact-form-plugin-html-email-templates) is wrong in the context of the Contact Form plugin.

Craft only takes the custom "HTML Template Path" email setting into account when [EmailService's](https://craftcms.com/classreference/services/EmailService) [sendEmailByKey](https://craftcms.com/classreference/services/EmailService#sendEmailByKey-detail) is called, which is used for pre-defined Craft emails.

The Contact Form uses [EmailService's](https://craftcms.com/classreference/services/EmailService) [sendEmail](https://craftcms.com/classreference/services/EmailService#sendEmail-detail), which won't take it into account.

It hasn't been released as part of an official Contact Form plugin release yet so there's no documentation, but thanks to [this pull request](https://github.com/pixelandtonic/ContactForm/commit/167e830665683deab22026ea3808d00f4b33e107), you've got an `onBeforeMessageCompile` event that will give a plugin a chance to modify the contents of the email.

> **Comments:**
> **username_0**: Thanks for clearing up the confusion. Easiest thing was just adding the template HTML to the email body within ContactFormService.php.  

---

### Answer by username_2 on 2019-04-02. Score: 1

For anyone interested, you can use [Contact Form Templates](https://github.com/lukeyouell/craft-contactformtemplates) to make custom email templates in Craft CMS 3.


---

### Answer by username_0 on 2016-07-28. Score: 1

As Brad points out in his answer, the Contact Form plugin doesn't use the same template. I found the easiest thing to do was replace:
$email->body      = $message->message;

with:
$htmlTemplateTopHalf= <<body      = $htmlTemplateTopHalf;
$email->body      .= $message->message;
$email->body      .= $htmlTemplateBottomHalf;


---

