首先,电子邮件完美无缺。
我只是遇到了一个使用password_resetting.email.twig和email.html.twig(在注册时确认您的电子邮件的问题)的渲染问题。
我只想弄清楚如何摆脱模板中HTML代码之前弹出的这些<br>
标签。 (见下面的代码或截图)
<!--- 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 --->
Screenshot from inspector in Inbox by Google
我完全按照文档中的内容编写了(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上随机拾取的基本HTML模板(https://github.com/leemunroe/responsive-html-email-template)
但<br>
标签仍然会弹出。
注意:如果我仅使用{%block body_text%},则没有额外的<br>
标记。它仅在我使用{%block body_html%}。
它来自FOSUserBundle吗?关于我缺少什么的任何想法?
测试中: - OSX 10.12.4:Spark客户端&amp;邮件客户端,位于Google,Gmail和Outlook的收件箱中的Chrome上。 - iOS10:Spark和Mail
如果需要,我的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 %}
答案 0 :(得分:0)
好吧,当然在{% block body_html %}
内我不需要<doctype html>
,也不需要<html>
标签。
通过删除所有内容(包括<head>
)但身体,我设法删除了这些<br>
标记。
我在<head>
中丢失了一些由MJML生成的样式属性,但电子邮件仍然正常显示。