When I load my custom template in Marketing->Email Templates
and look at the preview the email looks fine and includes the header, but when I send an email using the custom template only the footer is included, the header and css styles are not included.
How the template header and footer are added:
<!--@subject My Subject @-->
<!--@vars {
"var customer.email":"Customer Email",
"var customer.name":"Customer Name"
} @-->
{{template config_path="design/email/header_template"}}
template content
{{template config_path="design/email/footer_template"}}
Best Answer
I had a slightly different problem but i think it would be good to post the solution here anyway as I came across this post when researching my issue.
I have a custom module that triggers an email on a cron. The header and footer were not being included when the emails were sent.
The header and email templates are only located in the frontend area. See :
public/vendor/magento/module-email/view/
As such if your template options state 'adminhtml' or 'crontab' for example it wont find those templates.
In your custom code you will have a section or method containing something like this :
When you set your template options you need to make sure that you set the 'area' to be 'frontend' :
Equally, if your email template is in adminhtml/templates/email/ it will have to be moved to frontend/templates/email/
** Just want to add that this works on a single store configuration. If you are using multi-store configuration. You will need to pull the store id via a different mechanism, like: