我对电子邮件和扩展模板有疑问。我正在尝试为电子邮件构建一个模板,然后在不同的捆绑包中为电子邮件使用一个模板。我自己的包我成功地实现了这一点,但是当我尝试扩展 FosUserBundle 时出现问题:重置电子邮件。
我的模板在 app/Resources/views/email_base.html.twig
{% block subject %}{% endblock subject %}
<div dir="ltr" style="display: block; width: 100%; background: #ffffff">
<div class="gmail_quote">
<div style="margin:0;padding:20px 0; background: #ffffff">
<table align="center" bgcolor="#F9F9F9" cellpadding="0" width="600" style="border-spacing:20px 0;color:#4d4d4d;font-family:Arial,Helvetica">
<tbody>
TROLLOLOLL
{% block body_html %}
{% endblock body_html %}
</tbody>
</table>
<table align="center" bgcolor="#FFFFFF" width="600" style="margin-top:12px;color:#bdbdbd;font-family:Arial,Helvetica;font-size:11px;text-align:justify">
<tbody>
<tr>
<td colspan="4" style="padding-top:10px">
This e-mail is intended solely for the addressee, may contain proprietary and legally privileged information.
If you have received this e-mail by mistake please notify the sender and delete this e-mail along with all attachments.
Thank you.
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
我尝试使用模板扩展的电子邮件位于 UserBundle/Resources/views/Resetting/resetting_email.html.twig 中,如下所示:
{% extends '::email_base.html.twig' %}
{% block subject %}Resetting password
{% endblock %}
{% block body_html %}
<tr>
<td colspan=2 style="text-align: left;">
<h3>Witaj {{ user.username }}</h3>
</td>
</tr>
<tr>
<td colspan=2>
<p>Jeśli chcesz zresetować hasło, kliknij w następujący link <a style="color: #EA2227; text-decoration: underline" href="{{ confirmationUrl }}">reset hasła</a>.</p>
</td>
</tr>
{% endblock body_html %}
问题是当我发送此消息时,我只能看到来自resetting_email.html.twig 的内容。而且 base_email.html.twig 根本没有任何内容。
在我的配置文件中,我为我的文件resetting_email.html.twig 设置了重置模板:
fos_user:
db_driver: orm
firewall_name: main
user_class: GL\UserBundle\Entity\User
from_email:
address: development@##########.pl
sender_name: Admin ##########
resetting:
email:
template: GLUserBundle:Resetting:resetting_email.html.twig
service:
mailer: fos_user.mailer.twig_swift