Estou enviando um email usando Zend Framework 2, usando layout com tag devidamente <META content="text/html; charset=UTF-8" http-equiv=Content-Type>
configurada <head>
.
Quando coloco um link contendo o endereço IP no conteúdo do e-mail, o Outlook (versão 365) para de reconhecer o conjunto de caracteres corretamente e exibe o e-mail na codificação da Europa Ocidental (Windows).
Claro, se eu alterar a codificação em Ações -> Outras Ações -> Codificação para UTF-8, ela será exibida corretamente.
Você sabe como forçar o Outlook a exibir o e-mail em UTF-8?
Quando altero o link para não conter endereço IP, o Outlook reconhece a codificação UTF-8 corretamente, o único problema é quando o link contém endereço IP.
Verifiquei que há um problema apenas com $this->serverurl()
o método, mas como o endereço IP está codificado, o efeito é o mesmo: sem reconhecimento UTF-8.
Conteúdo do email (sem layout):
<?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']
);
?>
O e-mail é exibido assim (linguagem polonesa com caracteres diacríticos poloneses quebrados):
UWAGA. Wiadomość pochodzi z serwera DEWELOPERSKIEGO ZPB – prosimy jÄ… zignorować! DzieÅ„ dobry, zrealizowaliÅ›my Twój wniosek o zmiany w ZPB o nr 2019/2 z dnia 2019-08-13 12:43:32 TytuÅ‚: test Treść: testujemy różne rzeczy Jeżeli masz pytania . realizacji wniosku proszÄ™ ou contato com Help Desk nr tel xxx xxx xxx
HTML completo do e-mail:
<!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>
No servidor de produção $this->serverurl()
produzirá o endereço normal, mas nos servidores de teste sempre produzirá um endereço IP, o que não deve (mas atualmente o faz) quebrar o reconhecimento da codificação.
Verifiquei e no webmail o problema é o mesmo do Outlook, o GMail por outro lado o exibe corretamente.
Talvez possa ser um problema de configuração do servidor IMAP? Não sei nada sobre essas coisas.
Fiz a mesma pergunta no Stackoverflow, mas depois de considerar, acho que se adapta melhor aqui.
Cabeçalhos completos retirados das propriedades de email do 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==
Informações adicionais vistas na exibição da "mensagem original" do 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
Não há nada sobre codificação aqui, o charset é definido apenas na <head>
mensagem.