fosUserBundle sends email registration empty
Asked Answered
C

2

7

so when i registre via fosUserBundle form on production env it sends an email to my gmail but there is no confirmation link in the email, there is just this

registration.email.message

in the title and in the body of the email, someone knows why ?

Contracted answered 13/3, 2013 at 22:47 Comment(0)
C
13

It's because the email is content obtained using translator and you have wrong configuration.

Make sure you have the translator enabled:

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

# app/config/parameters.yml
parameters:
    locale: en # default locale

Also if you write your app in different language than english, make sure the key registration.email.message is translated into it. If it's not, you can override the translations by writing 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%.
Conah answered 13/3, 2013 at 23:8 Comment(1)
if it still not showing up. try to clear cache. it work for me after php app/console cache:clearMoneybags
A
0

This is the FOSUser default mail:

{% 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 %}

At line 8, 'registration.email.message' is the email content. And trans is a replace 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 %}
Assuming answered 13/12, 2014 at 21:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.