0

I am trying to set up a custom email template, it was work but shows an error after the template id is changed. May I know any way to fix it? Thanks!

app/code/Myvendor/Mymodule/etc/adminhtml/system.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
    <tab id="custom_tabs" translate="label" sortOrder="110">
        <label>Email Tabs</label>
    </tab>
    <section id="email_section" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1">
        <label>Custom Email send</label>
        <tab>custom_tabs</tab>
        <resource>Cleargo_ProductEnquiry::config</resource>
        <group id="sendmail" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
            <label>Email Setting</label>
            <field id="enabled" translate="label comment" type="select" sortOrder="10" showInDefault="1"
                   showInWebsite="1" showInStore="1">
                <label>Enabled</label>
                <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                <comment><![CDATA[Your Comments]]></comment>
            </field>
            <field id="sender" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="3" canRestore="1">
                <label>Product failed email sender</label>
                <source_model>Magento\Config\Model\Config\Source\Email\Identity</source_model>
                <depends>
                    <field id="enabled">1</field>
                </depends>
            </field>
            <field id="email_template" translate="label comment" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
                <label>Custom Email Template</label>
                <comment>Email template chosen based on theme fallback when "Default" option is selected.</comment>
                <source_model>Magento\Config\Model\Config\Source\Email\Template</source_model>
                <depends>
                    <field id="enabled">1</field>
                </depends>
            </field>
        </group>
    </section>

</system>

app/code/Myvendor/Mymodule/etc/config.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
    <email_section>
        <sendmail>
            <enabled>1</enabled>
            <sender>general</sender>
            <email_template>product_enquiry_email_template</email_template>
        </sendmail>
    </email_section>
</default>

app/code/Myvendor/Mymodule/etc/email_templates.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
    <email_section>
        <sendmail>
            <enabled>1</enabled>
            <sender>general</sender>
            <email_template>product_enquiry_email_template</email_template>
        </sendmail>
    </email_section>
</default>

Then I got the below error:

Exception #0 (UnexpectedValueException): Email template 'email_section_sendmail_email_template' is not defined.

1 Answer 1

0

Try the following steps:

  1. On the Admin sidebar, go to Stores > Settings > Configuration.

  2. In the left panel, expand Email Tabs and choose Custom Email send.

  3. In the Custom Email Template field, choose your new email template, and click Save Config.

  4. Clear the config cache type.

0

Your Answer

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

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