Incorrect behavior when sending email with use a block inside a template

When developing the module I encountered the following problem: inside the my controller (class Index extends \Magento\Framework\App\Action\Action) there is a method that calls a method to send email send() (inside class EmailSenderResultsSync extends AbstractHelper).

E-mail is sent and works well until the template file (view/frontend/email/sync-report/index.html) contains only html code, for example:

<h1>Title</h1>

But when I try to insert a block in the template as follows:

{{block class='Magento\\Framework\\View\\Element\\Template' area='frontend' template='<vendor>_<module>::email/sync-report/test.phtml' }}

an email is sent (along with the contents of the block) only 1 time. The next time you contact the controller (class Index extends \Magento\Framework\App\Action\Action), it does not work. The controller does not perform any actions at all.

There is no information in the logs.

I hope for help, thank you!

Solutions

You cannot call block like this in email template.

Here You have allowed customization for magento 2: https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/templates/template-email.html

Similar questions

How to disable the sending of Magento's default Success Email Template upon newsletter sign-up
Magento CE 1.9.0.1 We recently signed up for an email and list management service that taps into Magento and allows us to manage all transactional and newsletter emails through their application. This is a very convenient service and we would like to disable some of our outgoing Magento emails and just their service handle it. The only problem is t...
Sending custom email template in phtml file
How can i send a new Transactional Email with order information in the success.phtml? And how can i add custom order information?
Magento 1.9 i have added custom email template. need to preview customer before sending
I have added custom emails template it is working fine preview and in admin side transnational email section after loading code.But i need to implement preview section in front-end so when i load email template code It's printing array as output. Customer able to see preview before sending email.
Sending order confirmation email template in Magento 2
I am trying to send an order email confirmation with adding extra attributes values to Admin, But it's not working for me. Here I have 2 Email templates. 1) It's a default email template 2) Customized email template First one is the default, and it will send Magento by default. For the second one I tried below code, it's printing as it is table for...
Sending a welcome letter email next to the normal invoice email
After a customer has purchased a product from our Magento shop, he receives the invoice via email. That is working well. Now I want to send another email, a "welcome letter", to the same email address if the customer has purchased a product of a certain category. My question: Is there a built-in way (i.e. without PHP coding) to achieve that, tied t...
Sending custom email to multiple email address issue
This is my code: I received the email to this address: [email protected] But for [email protected] I do not receive any email. Why ?

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.