FosUserBundle Email Registration Blank

therefore, when I register through the fosUserBundle form when creating env, it sends an email to my gmail, but there is no confirmation link in the email, there is only this

registration.email.message 

in the header and body of the letter, does anyone know why?

+6
source share
2 answers

This is because the email is content obtained through the translator and you have the wrong configuration.

Make sure you have the translator turned on:

 # app/config/config.yml framework: translator: { fallback: %locale% } # app/config/parameters.yml parameters: locale: en # default locale 

Also, if you are writing your application in a language other than English, make sure that the registration.email.message key is translated into it. If this is not the case, you can override the translations by writing the following file:

 # app/Resources/FOSUserBundle/translations/FOSUserBundle.{your_locale}.yml registration: email: subject: Registration email subject message: | Here you can place the content of the email. It can be multiline and you even have access to variables %username% and %confirmationUrl%. 
+11
source

This is the default message for FOSUser:

 {% block subject %} {% autoescape false %} {{ 'registration.email.subject'|trans({'%username%': user.username, '%confirmationUrl%': confirmationUrl}, 'FOSUserBundle') }} {% endautoescape %} {% endblock %} {% block body_text %} {% autoescape false %} {{ 'registration.email.message'|trans({'%username%': user.username, '%confirmationUrl%': confirmationUrl}, 'FOSUserBundle') }} {% endautoescape %} {% endblock %} {% block body_html %}{% endblock %} 

On line 8, "registration.email.message" is the content of the email. And trans is a replacement filter. Try something like this:

  {% block subject %} {% autoescape false %} {{ 'Confirmez votre inscription sur blabla.com'|trans({'%username%': user.username, '%confirmationUrl%': confirmationUrl}, 'FOSUserBundle') }} {% endautoescape %} {% endblock %} {% block body_text %} {% autoescape false %} {{ 'Bonjour %username% Merci de cliquer sur le lien suivant afin de confirmer votre inscription sur blabla.com: %confirmationUrl%'|trans({'%username%': user.username, '%confirmationUrl%': confirmationUrl}, 'FOSUserBundle') }} {% endautoescape %} {% endblock %} {% block body_html %}{% endblock %} 
0
source

All Articles