I am having issues using twig templates for email in SF2.
First, I created a template file located at:
MainBundle/Resources/views/Email/InviteNewUsers.twig
Next, I rendered the view as the body of my email: $this->get('mailer')->send($this->renderView('MainBundle:Email:InviteNewUsers.twig', array('code' => $invite->getCode())));
Unfortunately, this triggers an error: Unable to find template "MainBundle:Email:InviteNewUsers.twig"
is there something wrong with my file placement or my render command?
It was suggest that I might need a type in the template name, so I tested with InviteNewUsers.txt.twig
and received the same error.
I believe the name of twig template needs to be InviteNewUsers.{_format}.twig
. so it must be something like InviteNewUsers.html.twig
, InviteNewUsers.xml.twig
, or InviteNewUsers.text.twig
etc
EDIT:
Also if your namespace includes first directory something like {Company}\BaseBundle\...
, then your template path needs to be {Company}MainBundle:Email:InviteNewUsers.text.twig
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With