5

magento\vendor\magento\module-contact\etc\email_templates.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:etc/email_templates.xsd">
    <template id="contact_email_email_template" label="Contact Form" file="submitted_form.html" type="text" module="Magento_Contact" area="adminhtml"/>
</config>

I have followed Magento 2: how to declare a custom email template for your module

Can we override in app\design or need to create custom module in app\code? If we can override using design then it will be better, because don't want to create new module for this.

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:etc/email_templates.xsd">
    <template id="contact_email_email_template" label="Contact Form" file="submitted_form.html" type="html" module="Magento_Contact" area="adminhtml"/>
</config>

Tried using magento\app\code\Custom\Module\etc\email_templates.xml But still not working. It's still taking Type as Text.

3

You need to create a new module for overwrite template config.

Your module.xml should be [Vendor/RewriteContact/etc/module.xml]

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Vendor_RewriteContact" setup_version="2.1.0">
        <sequence>
            <module name="Magento_Contact"/>
        </sequence>
    </module>
</config>

Now Vendor/RewriteContact/etc/email_templates.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:etc/email_templates.xsd">
    <template id="contact_email_email_template" label="Contact Form" file="submitted_form.html" type="html" module="Magento_Contact" area="adminhtml"/>
</config>

After changing module.xml file you need to run setup:upgrade command.

Clear cache.

3

Try creating new email template file in your custom module.

submitted_form.html

{{trans "Name: %name" name=$data.name}}
<br/>
{{trans "Email: %email" email=$data.email}}
<br/>
{{trans "Phone Number: %telephone" telephone=$data.telephone}}
<br/>
<br/>
{{trans "Comment: %comment" comment=$data.comment}}
<br/>

Now your email_templates.xml be like

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:etc/email_templates.xsd">
    <template id="jay_contact_email_email_template" label="Jay Contact Form" file="submitted_form.html" type="html" module="Jay_Contactform" area="adminhtml"/>
</config>

Most importantly, provide unique template identifier. ex: jay_contact_email_email_template

Now the html content would work fine.

  • Not showing on Admin -> Stores -> Configuration -> General -> Contacts : Email Options - Email Template – Ankit Shah Jan 4 '17 at 7:01
  • Yes. Adding templates via code is not listing over there. I don't know why. But if you want your template to be listed there, you can create new email template from admin back-end. – Mike Jan 4 '17 at 7:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.