jst*_*rdo 6 fosuserbundle symfony-2.3
我正在尝试为用户请求密码时发送的电子邮件定义我自己的模板,但在添加HTML部分时它不起作用.
这是模板:
{% trans_default_domain 'FOSUserBundle' %}
{% block subject %}
{% autoescape false %}
{{ 'resetting.email.subject'|trans({'%username%': user.username, '%confirmationUrl%': confirmationUrl}) }}
{% endautoescape %}
{% endblock %}
{% block body_text %}
{% autoescape false %}
{{ 'resetting.email.message'|trans({'%username%': user.username, '%confirmationUrl%': confirmationUrl}) }}
{% endautoescape %}
{% endblock %}
{% block body_html %}
{% autoescape false %}
<div dir="ltr" style="display: block; width: 100%; background: #ffffff">
<table style='width: 100%; border: none'>
<tr style='height: 20px; background-color: #5A82FF'>
<td></td>
</tr>
<tr>
<td style="padding: 30px 0; font-family: Verdana">
{{ 'resetting.email.message_html'|trans({'%username%': user.username, '%confirmationUrl%': confirmationUrl}) }}
</td>
</tr>
<tr style='height: 20px; background-color: #4ED53E'>
<td></td>
</tr>
</table>
</div>
{% endautoescape %}
{% endblock %}
Run Code Online (Sandbox Code Playgroud)
发送密码请求时,邮件以文本格式接收,其中嵌入了两个部分,这样:
Estimado jstuardo@desytec.com!
Para restablecer tu contraseña - por favor visita http://xxx.xxx.xxx.xxx
Atte,
El equipo de XXX
<div dir="ltr" style="display: block; width: 100%; background: #ffffff">
<table style='width: 100%; border: none'>
<tr style='height: 20px; background-color: #5A82FF'>
<td></td>
</tr>
<tr>
<td style="padding: 30px 0; font-family: Verdana">
Estimado jstuardo@desytec.com!
<br /><br />
Para restablecer tu contraseña - por favor visita http://xxx.xxx.xxx.xxx
<br /><br />
Atte,<br />
El equipo de XXX
</td>
</tr>
<tr style='height: 20px; background-color: #4ED53E'>
<td></td>
</tr>
</table>
</div>
Run Code Online (Sandbox Code Playgroud)
可能有什么不对?
谢谢Jaime
has*_*opf 18
我遇到了类似的问题.
默认邮件程序仅支持发送纯文本邮件.如果要发送多部分消息,最简单的解决方案是使用TwigSwiftMailer实现.它希望您的twig模板定义3个块:
subject 包含电子邮件主题body_text 呈现消息的纯文本版本body_html 呈现html邮件您必须在配置中设置服务(例如app/config/config.yml)
fos_user:
# ...
service:
mailer: fos_user.mailer.twig_swift
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4023 次 |
| 最近记录: |