我正在使用 Zend Framework 2 发送电子邮件,使用布局并正确设置<META content="text/html; charset=UTF-8" http-equiv=Content-Type>
标签<head>
。
当我在电子邮件内容中放置包含 IP 地址的链接时,Outlook(365 版)无法正确识别字符集,并以西欧(Windows)编码显示电子邮件。
当然,如果我在操作 -> 其他操作 -> 编码中将编码更改为 UTF-8,它就会正确显示。
您是否知道如何强制 Outlook 以 UTF-8 显示电子邮件?
当我将链接更改为不包含 IP 地址时,Outlook 可以正确识别 UTF-8 编码,唯一的问题是当链接包含 IP 地址时。
我检查了一下,发现只有$this->serverurl()
方法存在问题,但鉴于 IP 地址是硬编码的,效果是一样的:无法识别 UTF-8。
电子邮件内容(不含布局):
<?php
echo sprintf(
$this->translate('scp.notification.done'),
'<a href="'.$this->serverurl() . $this->url('system-change-proposal/view', array('id' => $this->id)) . '">' . $this->info['PROPOSAL_NUMBER'] . '</a><br/>',
$this->info['CREATE_DATE'] . '<br/>',
$this->info['TOPIC'] . '<br/>',
$this->info['CONTENT']
);
?>
电子邮件显示如下(波兰语,带有损坏的波兰语变音符号):
呜哇嘎。感谢您一直以来的支持,我们期待与您的合作!今天,我终于可以和 ZPB 一起度过 2019/2 下午 2019-08-13 12:43:32 日期:test 主题:testing 我经常被问到这个问题。实现梦想之旅或联系帮助台 nr 电话 xxx xxx xxx
电子邮件的完整 HTML:
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Simple Transactional Email</title>
<style>
/* -------------------------------------
GLOBAL RESETS
------------------------------------- */
img {
border: none;
-ms-interpolation-mode: bicubic;
max-width: 100%; }
body {
background-color: #f6f6f6;
font-family: sans-serif;
-webkit-font-smoothing: antialiased;
font-size: 14px;
line-height: 1.4;
margin: 0;
padding: 0;
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%; }
table {
border-collapse: separate;
mso-table-lspace: 0pt;
mso-table-rspace: 0pt;
width: 100%; }
table td {
font-family: sans-serif;
font-size: 14px;
vertical-align: top; }
/* -------------------------------------
BODY & CONTAINER
------------------------------------- */
.body {
background-color: #f6f6f6;
width: 100%; }
/* Set a max-width, and make it display as block so it will automatically stretch to that width, but will also shrink down on a phone or something */
.container {
display: block;
Margin: 0 auto !important;
/* makes it centered */
max-width: 800px;
padding: 10px;
width: 800px; }
/* This should also be a block element, so that it will fill 100% of the .container */
.content {
box-sizing: border-box;
display: block;
Margin: 0 auto;
max-width: 800px;
padding: 10px; }
/* -------------------------------------
HEADER, FOOTER, MAIN
------------------------------------- */
.main {
background: #fff;
border-radius: 3px;
width: 100%; }
.wrapper {
box-sizing: border-box;
padding: 20px; }
.footer {
clear: both;
padding-top: 10px;
text-align: center;
width: 100%; }
.footer td,
.footer p,
.footer span,
.footer a {
color: #999999;
font-size: 12px;
text-align: center; }
/* -------------------------------------
TYPOGRAPHY
------------------------------------- */
h1,
h2,
h3,
h4 {
color: #000000;
font-family: sans-serif;
font-weight: 400;
line-height: 1.4;
margin: 0;
Margin-bottom: 30px; }
h1 {
font-size: 35px;
font-weight: 300;
text-align: center;
text-transform: capitalize; }
p,
ul,
ol {
font-family: sans-serif;
font-size: 14px;
font-weight: normal;
margin: 0;
Margin-bottom: 15px; }
p li,
ul li,
ol li {
list-style-position: inside;
margin-left: 5px; }
a {
color: #3498db;
text-decoration: underline; }
.text-left {
text-align: left;
}
.text-right {
text-align: right;
}
.text-center {
text-align: center;
}
.text-justify {
text-align: justify;
}
.text-nowrap {
white-space: nowrap;
}
.table {
border-spacing: 0;
border-collapse: collapse;
}
td,
th {
padding: 0.5em;
}
.zpb-table th {
padding:7px;
padding-top:4px;
padding-bottom:4px;
font-weight:bold;
text-align:center;
background-color:#F6F6F6;
border-right: 1px solid #D2E9EF;
box-shadow: 0px 2px 5px #888888;
}
.zpb-table td {
vertical-align: middle !important;
}
.table-bordered th,
.table-bordered td {
border: 1px solid #ddd !important;
}
.alert {
padding: 15px;
margin-bottom: 20px;
border: 1px solid transparent;
border-radius: 4px;
}
.alert-warning {
color: #8a6d3b;
background-color: #fcf8e3;
border-color: #faebcc;
}
/* -------------------------------------
BUTTONS
------------------------------------- */
.btn {
box-sizing: border-box;
width: 100%; }
.btn > tbody > tr > td {
padding-bottom: 15px; }
.btn table {
width: auto; }
.btn table td {
background-color: #ffffff;
border-radius: 5px;
text-align: center; }
.btn a {
background-color: #ffffff;
border: solid 1px #3498db;
border-radius: 5px;
box-sizing: border-box;
color: #3498db;
cursor: pointer;
display: inline-block;
font-size: 14px;
font-weight: bold;
margin: 0;
padding: 12px 25px;
text-decoration: none;
}
.btn-primary table td {
background-color: #3498db; }
.btn-primary a {
background-color: #3498db;
border-color: #3498db;
color: #ffffff; }
/* -------------------------------------
OTHER STYLES THAT MIGHT BE USEFUL
------------------------------------- */
.last {
margin-bottom: 0; }
.first {
margin-top: 0; }
.align-center {
text-align: center; }
.align-right {
text-align: right; }
.align-left {
text-align: left; }
.clear {
clear: both; }
.mt0 {
margin-top: 0; }
.mb0 {
margin-bottom: 0; }
.preheader {
color: transparent;
display: none;
height: 0;
max-height: 0;
max-width: 0;
opacity: 0;
overflow: hidden;
mso-hide: all;
visibility: hidden;
width: 0; }
.powered-by a {
text-decoration: none; }
hr {
border: 0;
border-bottom: 1px solid #f6f6f6;
Margin: 20px 0; }
.table-bordered th,
.table-bordered td {
border: 1px solid #ddd !important;
}
/* -------------------------------------
RESPONSIVE AND MOBILE FRIENDLY STYLES
------------------------------------- */
@media only screen and (max-width: 620px) {
table[class=body] h1 {
font-size: 28px !important;
margin-bottom: 10px !important; }
table[class=body] p,
table[class=body] ul,
table[class=body] ol,
table[class=body] td,
table[class=body] span,
table[class=body] a {
font-size: 16px !important; }
table[class=body] .wrapper,
table[class=body] .article {
padding: 10px !important; }
table[class=body] .content {
padding: 0 !important; }
table[class=body] .container {
padding: 0 !important;
width: 100% !important; }
table[class=body] .main {
border-left-width: 0 !important;
border-radius: 0 !important;
border-right-width: 0 !important; }
table[class=body] .btn table {
width: 100% !important; }
table[class=body] .btn a {
width: 100% !important; }
table[class=body] .img-responsive {
height: auto !important;
max-width: 100% !important;
width: auto !important; }}
/* -------------------------------------
PRESERVE THESE STYLES IN THE HEAD
------------------------------------- */
@media all {
.ExternalClass {
width: 100%; }
.ExternalClass,
.ExternalClass p,
.ExternalClass span,
.ExternalClass font,
.ExternalClass td,
.ExternalClass div {
line-height: 100%; }
.apple-link a {
color: inherit !important;
font-family: inherit !important;
font-size: inherit !important;
font-weight: inherit !important;
line-height: inherit !important;
text-decoration: none !important; }
.btn-primary table td:hover {
background-color: #34495e !important; }
.btn-primary a:hover {
background-color: #34495e !important;
border-color: #34495e !important; } }
</style>
</head>
<body class="">
<table border="0" cellpadding="0" cellspacing="0" class="body">
<tr>
<td> </td>
<td class="container">
<div class="content">
<table class="main">
<tr>
<td>
<span style="color: #ee0000; font-size: 17px;">
UWAGA. Wiadomość pochodzi z serwera DEWELOPERSKIEGO ZPB – prosimy ją zignorować! </span>
</td>
</tr>
<tr>
<td class="wrapper">Dzień dobry, zrealizowaliśmy Twój wniosek o zmiany w ZPB o nr <a href="http://zpb//scp/view/5613">2019/2</a><br/> z dnia 2019-08-13 12:43:32<br/> Tytuł: test<br/> Ttreść: testujemy różne rzeczy Jeżeli masz pytania dot. realizacji wniosku proszę o kontakt z Help Desk nr tel xxx xxx xxx<br/>
</td>
</tr>
</table>
</div>
</td>
<td> </td>
</tr>
</table>
</body>
</html>
在生产服务器上将$this->serverurl()
输出正常地址,但在测试服务器上它将始终输出 IP 地址,这不应该(但目前确实)破坏编码识别。
我检查了一下,在 Webmail 中,问题与 Outlook 中的问题相同,而 GMail 则正确显示它。
也许这可能是 IMAP 服务器配置问题?我对这类事情一无所知。
我在 Stackoverflow 上问了同样的问题,但经过考虑,我认为它更适合在这里。
从 Outlook 电子邮件属性中提取的完整标头:
Received: from 195.245.224.194 (HELO mx-1.tauron.pl) (195.245.224.194)
by 94.152.180.72 with SMTP; 20 Aug 2019 07:27:18 -0000
Received: (qmail 43535 invoked by uid 1272007); 20 Aug 2019 07:27:18 -0000
Received: from poczta.tpe.corp (10.170.11.93) by
TPCE-EXCA01V-TD-ZPB-new-version.tpe.corp (10.170.6.50) with Microsoft SMTP
Server id 14.3.408.0; Tue, 20 Aug 2019 09:27:14 +0200
Received: from unknown (HELO poczta.tpe.corp) ([10.170.6.40])
by mx-1.tauron.pl with ESMTP; 20 Aug 2019 09:27:15 +0200
From: "TD Zarzadzanie Praca Brygad" <[email protected]>
To: <[email protected]>
Subject: Zrealizowano wniosek o zmiany 2019/2
Date: Tue, 20 Aug 2019 09:27:14 +0200
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_0000_01D5573A.4D3DE7C0"
X-Mailer: Microsoft Outlook 16.0
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on 3010302.s.tld.pl
X-Spam-Flag: YES
X-Spam-Level: *******
X-Spam-Report: =?ISO-8859-1?Q?
* -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at
* https://www.dnswl.org/, no trust
* [195.245.224.194 listed in list.dnswl.org]
* -1.5 BAYES_00 BODY: Bayesowskie prawdopodobie=f1stwo spamu wynosi 0 do
* 1%
* [score: 0.0000]
* -0.1 SPF_HELO_PASS SPF: HELO matches SPF record
* 8.1 WEIRD_PORT URI: U=bfywa niestandardowego numeru portu dla HTTP
* 0.7 MIME_HTML_ONLY BODY: Wiadomo=b6=e6 posiada tylko cz=ea=b6ci
* tekstowe/html MIME
* 0.0 HTML_MESSAGE BODY: Wiadomo=b6=e6 zawiera kod HTML?=
X-Spam-Relay-Country: PL ** **
X-IronPort-AV: E=Sophos;i="5.64,408,1559512800";
d="scan'208,217";a="76099017"
X-IronPort-AV: E=McAfee;i="6000,8403,9354"; a="76099017"
X-C2ProcessedOrg: 5199a320-9f4c-49ed-bc0e-d8ad42683a42
X-Spam-Status: Yes, score=7.2 required=5.0 tests=BAYES_00,HTML_MESSAGE, MIME_HTML_ONLY,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,WEIRD_PORT autolearn=disabled version=3.4.2
X-EsetId: 37303A29D5F1F66E61726A
Thread-Index: AQKbkkKOZgQGewYhh0xjSjHTj+sQ2w==
GMail 在“原始邮件”显示中看到的附加信息:
MIME-Version: 1.0
Content-Type: text/html
Content-Transfer-Encoding: 8bit
From: "TD Zarządzanie Pracą Brygad" <[email protected]>
To: <[email protected]>
Subject: Zrealizowano wniosek o zmiany 2019/2
这里没有关于编码的任何内容,字符集仅在<head>
消息中设置。