FOSUserBundle to reset HTML email template not working

I am trying to define my own email template, which is sent when the user asks for a password, but it does not work when adding part of the HTML.

This is the template:

{% trans_default_domain 'FOSUserBundle' %} {% block subject %} {% autoescape false %} {{ 'resetting.email.subject'|trans({'%username%': user.username, '%confirmationUrl%': confirmationUrl}) }} {% endautoescape %} {% endblock %} {% block body_text %} {% autoescape false %} {{ 'resetting.email.message'|trans({'%username%': user.username, '%confirmationUrl%': confirmationUrl}) }} {% endautoescape %} {% endblock %} {% block body_html %} {% autoescape false %} <div dir="ltr" style="display: block; width: 100%; background: #ffffff"> <table style='width: 100%; border: none'> <tr style='height: 20px; background-color: #5A82FF'> <td></td> </tr> <tr> <td style="padding: 30px 0; font-family: Verdana"> {{ 'resetting.email.message_html'|trans({'%username%': user.username, '%confirmationUrl%': confirmationUrl}) }} </td> </tr> <tr style='height: 20px; background-color: #4ED53E'> <td></td> </tr> </table> </div> {% endautoescape %} {% endblock %} 

When a password request is sent, mail is received in text format with parts embedded in it, thus:

 Estimado jstuardo@desytec.com ! Para restablecer tu contraseña - por favor visita http://xxx.xxx.xxx.xxx Atte, El equipo de XXX <div dir="ltr" style="display: block; width: 100%; background: #ffffff"> <table style='width: 100%; border: none'> <tr style='height: 20px; background-color: #5A82FF'> <td></td> </tr> <tr> <td style="padding: 30px 0; font-family: Verdana"> Estimado jstuardo@desytec.com ! <br /><br /> Para restablecer tu contraseña - por favor visita http://xxx.xxx.xxx.xxx <br /><br /> Atte,<br /> El equipo de XXX </td> </tr> <tr style='height: 20px; background-color: #4ED53E'> <td></td> </tr> </table> </div> 

What could be wrong?

Thanks Jaime

+6
source share
1 answer

I had a similar problem.

By default, the email program only supports sending text messages. If you want to send multi-page messages, the easiest solution is to use the TwigSwiftMailer implementation. It expects your branch template to define 3 blocks:

  • subject containing email subject
  • body_text display the text version of the message
  • body_html display html mail

You must install the service in config (e.g. app / config / config.yml)

 fos_user: # ... service: mailer: fos_user.mailer.twig_swift 
+16
source

All Articles