I have created an email template for my custom form as follows:
Vendor/Module/etc/email_templates.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:Magento:module:Magento_Email:etc/email_templates.xsd">
<template id="custom_email_template" label="Warranty Email" file="custom_email_template.html" type="html" module="Vendor_Module" area="frontend"/>
</config>
and created the template file in
app/design/frontent/Vendor/Theme/Vendor_Module/email/custom_email_template.html
Now when I create a new template in Marketing -> Email templates I am able to see my new created template in the dropdown. I put the content for the template and save it in admin. But when the email is sent, it is sent from the custom_email_template.html content and not the content from the admin template.
I am sending email programmatically as follows:
$this->inlineTranslation->suspend();
$sender = [
'name' => $this->escaper->escapeHtml('Sufyan Khot'),
'email' => $this->escaper->escapeHtml('[email protected]'),
];
$transport = $this->transportBuilder
->setTemplateIdentifier('custom_email_template')
->setTemplateOptions(
[
'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
'store' => 2,
]
)
->setTemplateVars([
'templateVar' => 'Custom email',
])
->setFrom($sender)
->addTo('[email protected]')
->getTransport();
$transport->sendMessage();
$this->inlineTranslation->resume();
You can see I have put the template id as custom_email_template
as specified in email_template.xml
. When I check in the database I cannot find any column for email template I created in admin.
I want to send the content from the email template created in admin and not from the html file.