Magento 2.2 – Add Default Header and Footer to Custom Email

customemailevent-observermagento2module

I have created a module where I send a custom mail.
For this, I have a custom email template.

Now what I want to do is to include the default header and footer that appears in all my Magento emails, in my custom mail.

I tried to include the header and the footer like this but is not working:

{{template config_path="design/email/header_template"}}
 ...content
{{template config_path="design/email/footer_template"}}

and my 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="myid" label="mylabel" file="myfile.html" type="html" module="mymodule" area="frontend"/>
</config>

I need to include also the header template and footer in my custom module because I think that my custom mail doesn't know what is header_template and footer_template? If yes, from where I can take this file and where I should put it?

Thank you in advance!

Best Answer

In place of {{template config_path="design/email/header_template"}} you can use the its HTML code.

You can get the HTML codes for header and footer from this path:

/magento/vendor/magento/module-email/view/frontend/email

Place this code into your HTML file. May this works for you.