1
我想在註冊後發送確認電子郵件給用戶。我自定義了電子郵件模板,以便用戶可以收到帶有確認URL的電子郵件。FOSUser電子郵件確認不起作用
這是我的配置
fos_user:
# ...
service:
mailer: fos_user.mailer.twig_swift
registration:
confirmation:
template: AppBundle:Email:registration.email.twig
from_email:
address: [email protected]
sender_name: Example
這是我的模板
{% block subject %}Registration Success{% endblock %}
{% block body_text %}
{% autoescape false %}
Hello {{ user.fullName }}!
Thanks for registering
<p><a href="{{ confirmationUrl }}">verify</a></p>
Greetings,
CofiCo team
{% endautoescape %}
{% endblock %}
我觸發電子郵件在我的控制器手動發送:
$token = sha1(uniqid(mt_rand(), true));
$user->setConfirmationToken($token);
$this->get('fos_user.mailer')->sendConfirmationEmailMessage($user);
電子郵件是不是跟這個發送模板。但是,如果我從模板中刪除{{ confirmationUrl }}
,電子郵件發送工作正常。
如何使用確認URL發送電子郵件?