0

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.

2 Answers 2

0

add your content of email templates in app/design/frontent/Vendor/Theme/Vendor_Module/email/custom_email_template.html

0

Try Checking this template in email marketing templates in Magento admin. But first create a demo content HTML template in this location.

add your content of email templates in app/design/frontent/Vendor/Theme/Vendor_Module/email/custom_email_template.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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