问题描述
我正在使用symfony mailer component,并用树枝制作HTML模板。
在symfony探查器电子邮件部分中发送电子邮件后,原始内容是我无法理解的!
这是我的代码:
$email = (new TemplatedEmail())
->from(new Address($this->container->getParameter('mailer_no_replay'),'B2B Marketing'))//Todo: Translation
->to(new Address($lead->getEmail(),$lead->getName()))
->subject($emailTemplate->getSubject())
->htmlTemplate('emails/email-messages/crm-email.html.twig')
->context([
'user' => $lead,'content' => $mailContent,]);
$this->mailer->send($email);
和模板:
1:孩子(扩展2)
{% extends 'emails/content-email.html.twig' %}
{% block emailMessage %}
{{ content | raw}}
{% endblock %}
2:父级
{% extends 'emails/emailBase.html.twig' %}
{#
This Template used for rendering emails that just have a content not need to render anything else
#}
{% block content %}
<div style="background-color:#ffffff;">
<div class="block-grid"
style="Margin: 0 auto; min-width: 320px; max-width: 790px; overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; background-color: #e8f5f8;">
<div style="border-collapse: collapse;display: table;width: 100%;background-color:#e8f5f8;">
<!--[if (mso)|(IE)]>
<table width="100%" cellpadding="0" cellspacing="0" border="0"
style="background-color:#ffffff;">
<tr>
<td align="center">
<table cellpadding="0" cellspacing="0" border="0" style="width:790px">
<tr class="layout-full-width" style="background-color:#e8f5f8"><![endif]-->
<!--[if (mso)|(IE)]>
<td align="center" width="790"
style="background-color:#e8f5f8;width:790px; border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent;"
valign="top">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="padding-right: 25px; padding-left: 25px; padding-top:60px; padding-bottom:60px;">
<![endif]-->
<div class="col num12"
style="min-width: 320px; max-width: 790px; display: table-cell; vertical-align: top; width: 790px;">
<div style="width:100% !important;">
<!--[if (!mso)&(!IE)]><!-->
<div
style="border-top:0px solid transparent; border-left:0px solid transparent; border-bottom:0px solid transparent; border-right:0px solid transparent; padding-top:60px; padding-bottom:60px; padding-right: 25px; padding-left: 25px;">
<!--<![endif]-->
<!--[if mso]>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="padding-right: 20px; padding-left: 20px; padding-top: 10px; padding-bottom: 5px; font-family: Arial,sans-serif">
<![endif]-->
<div
style="color:#34495e;font-family:Open Sans,Helvetica Neue,Helvetica,Arial,sans-serif;line-height:1.5;padding-right:20px;padding-bottom:5px;padding-left:20px;">
<div
style="line-height: 1.5; font-size: 13px; color: #34495e; font-family: Open Sans,sans-serif; mso-line-height-alt: 18px;">
{% block emailMessage %}{% endblock %}
</div>
</div>
</div>
<!--<![endif]-->
</div>
</div>
<!--[if (mso)|(IE)]></td></tr></table><![endif]-->
<!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
</div>
</div>
</div>
{% endblock %}
解决方法
这些字符是:
引用可打印或QP编码是使用可打印ASCII字符的二进制到文本编码系统。 QP通过将等号=用作转义字符来工作。
示例: 以下示例是法语文本(以UTF-8编码),带有带有变音符号的字母(例如é)的频率很高。
J'interdis aux marchands de vanter trop leurs marchandises. Car ils se font=
vite p=C3=A9dagogues et t'enseignent comme but ce qui n'est par essence qu=
'un moyen,et te trompant ainsi sur la route =C3=A0 suivre les voil=C3=
=A0 bient=C3=B4t qui te d=C3=A9gradent,car si leur musique est vulgaire il=
s te fabriquent pour te la vendre une =C3=A2me vulgaire.
=E2=80=94=E2=80=89Antoine de Saint-Exup=C3=A9ry,Citadelle (1948)
此代码编码为以下引用:
J'interdis aux marchands de vanter trop leurs marchandises。 Car il se字样在各种语言中起着举足轻重的作用,但从本质上来说却颇具特色,例如qu'un moyen以及suprêantsu ivre lesvoilàbientôtqui tedégradent,汽车之声te la vendre uneâmevulgaire。
—安托万·圣埃修伯里,城堡(1948)
更多详细信息:https://en.wikipedia.org/wiki/Quoted-printable
感谢味精。