2013-03-13 123 views
6

所以,當我通過對生產ENV fosUserBundle形式登記簿發送電子郵件到我的Gmail但在電子郵件中未確認鏈接,還有就是這個fosUserBundle發送電子郵件報名空

registration.email.message 
在標題

和在電子郵件的正文中,有人知道爲什麼?

回答

11

這是因爲電子郵件是使用翻譯器獲得的內容,並且您的配置錯誤。

請確保您有啓用譯者:

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

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

此外,如果你寫在不同的語言不是英語的應用,確保關鍵registration.email.message被翻譯成它。如果不是,則可以覆蓋書面翻譯下列文件:

# 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%. 
+0

如果它仍然沒有顯示出來。嘗試清除緩存。它適用於我後 php應用程序/控制檯緩存:清除 – 2014-02-20 12:44:36

+0

完美的作品。非常感謝。 – mtchuente 2016-08-17 04:44:24

0

這是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 %} 

在第8行,「registration.email.message」是郵件內容。而trans是一個替換過濾器。嘗試這樣的:

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