首先,电子邮件工作得很好。
我只是在 password_resetting.email.twig 和 email.html.twig (用于确认您的注册电子邮件)的渲染问题。
我只是想弄清楚如何摆脱<br>
在我的模板中的 HTML 代码之前弹出的这些标签。(见下面的代码或截图)
<!--- Taken in my Inbox --->
<div jstcache="3332" class="i3" jsaction="jsl._" jsan="7.i3,22.jsaction"><!--- Div generated by Google --->
<br> <!--- Beginning of the email body obviously --->
<br>
<u></u>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<div style="background:#eaeced"><!--- Beginning of the real HTML body that I created --->
<br>
<div style="background-color:#eaeced">
<!--- No need to show you the rest of the email --->
我完全按照文档(symfonydoc:FOSUserBundle/emails.html)中所写的内容进行了操作。
我测试了有和没有:
{% block subject %}Resetting your password{% endblock %}
{% block body_text %}
{% autoescape false %}
Hello {{ user.username }} !
You can reset your password by accessing {{ confirmationUrl }}
Greetings,
the App team
{% endautoescape %}
{% endblock %}
我使用 MJML 框架编写了我的 HTML 电子邮件。我想了一会儿,MJML CLI 没有正确呈现它。因此,我使用在 github ( https://github.com/leemunroe/responsive-html-email-template ) 上随机选取的基本 HTML 模板进行了测试,但<br>
标签仍然弹出。
注意:如果我只使用 {% block body_text %} 就没有额外的<br>
标签。它仅在我使用 {% block body_html %} 时发生。
它来自 FOSUserBundle 吗?关于我缺少什么的任何想法?
在以下环境中测试:- OSX 10.12.4:Spark 客户端和邮件客户端,在 Google、Gmail 和 Outlook 的收件箱中的 Chrome 上。 - iOS10:Spark 和邮件
如果需要,我的 HTML.twig 模板带有假数据
{% block subject %}Resetting your password{% endblock %}
{% block body_text %}
{% autoescape false %}
Hello {{ user.username }} !
You can reset your password by accessing {{ confirmationUrl }}
Greetings,
the App team
{% endautoescape %}
{% endblock %}
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<title></title>
<!--[if !mso]><!-- -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!--<![endif]-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
#outlook a { padding: 0; }
.ReadMsgBody { width: 100%; }
.ExternalClass { width: 100%; }
.ExternalClass * { line-height:100%; }
body { margin: 0; padding: 0; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
table, td { border-collapse:collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; }
img { border: 0; height: auto; line-height: 100%; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; }
p { display: block; margin: 13px 0; }
</style>
<!--[if !mso]><!-->
<style type="text/css">
@media only screen and (max-width:480px) {
@-ms-viewport { width:320px; }
@viewport { width:320px; }
}
</style>
<!--<![endif]-->
<!--[if mso]>
<xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
<o:PixelsPerInch>96</o:PixelsPerInch>
</o:OfficeDocumentSettings>
</xml>
<![endif]-->
<!--[if lte mso 11]>
<style type="text/css">
.outlook-group-fix {
width:100% !important;
}
</style>
<![endif]-->
<!--[if !mso]><!-->
<link href="https://fonts.googleapis.com/css?family=Poppins:400,600,700" rel="stylesheet" type="text/css">
<style type="text/css">
@import url(https://fonts.googleapis.com/css?family=Poppins:400,600,700);
</style>
<!--<![endif]--><style type="text/css">
@media only screen and (min-width:480px) {
.mj-column-per-100 { width:100%!important; }
}
</style>
</head>
<body style="background: #eaeced;">
<div style="background-color:#eaeced;"><!--[if mso | IE]>
<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="600" align="center" style="width:600px;">
<tr>
<td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">
<![endif]--><div style="margin:0px auto;max-width:600px;background:#fff;"><table role="presentation" cellpadding="0" cellspacing="0" style="font-size:0px;width:100%;background:#fff;" align="center" border="0"><tbody><tr><td style="text-align:center;vertical-align:middle;direction:ltr;font-size:0px;padding:20px 0px;padding-top:80px;"><!--[if mso | IE]>
<table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td style="vertical-align:middle;width:600px;">
<![endif]--><div class="mj-column-per-100 outlook-group-fix" style="vertical-align:middle;display:inline-block;direction:ltr;font-size:13px;text-align:left;width:100%;"><table role="presentation" cellpadding="0" cellspacing="0" style="vertical-align:middle;" width="100%" border="0"><tbody><tr><td style="word-break:break-word;font-size:0px;padding:10px 25px;padding-top:45px;padding-bottom:20px;padding-right:30px;padding-left:50px;" align="left"><div class="" style="cursor:auto;color:#000;font-family:Poppins, -apple-system, BlinkMacSystemFont, Helvetica Neue, Arial, sans-serif;font-size:22px;font-weight:700;line-height:2em;text-align:left;">
<span style="font-weight: 700;color:#009EF5; border-bottom: 5px solid #009EF5">Confirmez</span> votre compte LVDF
</div></td></tr><tr><td style="word-break:break-word;font-size:0px;padding:10px 25px;padding-bottom:10px;padding-right:30px;padding-left:50px;" align="left"><div class="" style="cursor:auto;color:#9b9b9b;font-family:Poppins, -apple-system, BlinkMacSystemFont, Helvetica Neue, Arial, sans-serif;font-size:15px;line-height:22px;text-align:left;">
Hello {{ user.username }}, <br><br>
"Random String here"
</div></td></tr><tr><td style="word-break:break-word;font-size:0px;padding:10px 25px;padding-top:10px;padding-bottom:45px;" align="center"><table role="presentation" cellpadding="0" cellspacing="0" style="border-collapse:separate;" align="center" border="0"><tbody><tr><td style="border:none;border-radius:25px;color:#fff;cursor:auto;padding:12px 50px;" align="center" valign="middle" bgcolor="#009EF5"><a href="{{ confirmationUrl }}" style="text-decoration:none;line-height:100%;background:#009EF5;color:#fff;font-family:Poppins, -apple-system, BlinkMacSystemFont, Helvetica Neue, Arial, sans-serif;font-size:18px;font-weight:600;text-transform:none;margin:0px;" target="_blank">Confirmer
</a></td></tr></tbody></table></td></tr><tr><td style="word-break:break-word;font-size:0px;padding:10px 25px;padding-bottom:10px;padding-right:30px;padding-left:50px;" align="left"><div class="" style="cursor:auto;color:#9b9b9b;font-family:Poppins, -apple-system, BlinkMacSystemFont, Helvetica Neue, Arial, sans-serif;font-size:15px;line-height:22px;text-align:left;">
<span style="font-weight: 600; color:#9B9B9B;">the team<br><br> <a href="#" style="display:inline-block;text-decoration:none;color:#9b9b9b;" target="_blank"><strong>mysite.io</strong></a></span>
</div></td></tr></tbody></table></div><!--[if mso | IE]>
</td></tr></table>
<![endif]--></td></tr></tbody></table></div><!--[if mso | IE]>
</td></tr></table>
<![endif]--></div>
</body>
</html>
{% endblock %}