I need to pass the phtml file into email template. but I'm getting error like

Error Log :

Error filtering template: Invalid template file: 'Vendor_Module::emailproducts.phtml' in module: '' block's name: 'magento\framework\view\element\template_0'

I used below code in email template.

{{block class="Magento\Framework\View\Element\Template" name="email_template" area='frontend' template="Vendor_Module::emailproducts.phtml"}}

Phtml template file path


Thanks in advance.


2 Answers 2


You need to pass something like below in your email.html file.

   {{layout handle="product_stock_alert_items"}}

Create layout file as product_stock_alert_items.xml in layout folder. Add content in it like below.

<?xml version="1.0"?>
    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" design_abstraction="custom">
             <block class="Magento\ProductAlert\Block\Email\Stock" name="productalert.stock.alert" template="Magento_ProductAlert::stock.phtml" cacheable="false" />

And now create .phtml as stock.phtml in template folder and add your phtml content in it.

  • Magento 1 How to add website filter in app\locale\en_US\template\email\sales\order_new.phtml, my workout => paste.ofcode.org/G7k6QZMMEMHE8yHCH3kj6z any help thanks @Kazim Noorani
    – Gem
    Mar 17, 2020 at 10:38

There is an issue in your Email template file. Your given template file is not found in an assigned block(Magento\Framework\View\Element\Template). so you need to create a custom block and have to assign that block to the phtml file.

And extend your custom block to Magento\Framework\View\Element\Template

Check below detail description example.


<tr class="email-information">
        {{layout handle="test_email_log_order_items" items=$items area="frontend"}}


<block class="Namespace\Modulename\Block\EmailLog\Items" name="items" template="email/items.phtml" cacheable="false"></block>


namespace Namespace\Modulename\Block\EmailLog;

class Items extends \Magento\Framework\View\Element\Template

    public function __construct(
        \Magento\Framework\View\Element\Template\Context $context, 
        array $data = array()
    ) {
        parent::__construct($context, $data);        



echo "This data is dynamic data and can be changed according to need.";
// You can print data according to your need. 
// You can also get the parameters on this file.


<template id="test_email_template" label="Test email template" file="test_reminder.html" type="html" module="Namespace_Modulename" area="frontend"/>

If you are giving a select email template in system configuration then your config.xml should be like below.



That's it. It's work for me! I hope it helps.

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .