PHPMailer
でHTMLメール(およびフォールバックプレーンテキスト)を送信しようとしています。私の問題は、電子メールを受け取ったときに、HTMLコードが追加されたため、HTMLコードがすべて失われることです。PHPMailerを電子メールとして送信するときにHTMLコードを保存する方法
私は8bit
または7bit
のいずれかに、quoted-printable
からエンコーディングを変更しようとしましたが、phpmailerのは、ただ単にquoted-printable
たびに戻ります。
私はこの答えにこの原因を見つけることができた:https://stackoverflow.com/a/33102397/2691879
は基本的に、それは電子メールを送信する際に、すべての998個の文字の後に改行を追加することが必須であること、のように見えますが、私の質問は、どのようにして電子メールを送信している間、HTMLコードが保存されることを保証することができますか?
ここに何か不足していますか?
残念ながら、私が使用しているテンプレートに改行を手動で追加することは、このコードの意図された使用が送信される独自のテンプレートを作成できるため、また、テンプレートには、送信前に置き換えられる可変データがあります。
ここにいくつかのコードです:、
self::$Mailer->addAddress($to);
self::$Mailer->Subject=$subject;
self::$Mailer->Body=$template['html'];
self::$Mailer->AltBody=$template['text'];
self::$Mailer->CharSet = 'UTF-8';
self::$Mailer->Encoding = '7bit';
self::$Mailer->send();
私が使用してHTMLテンプレート以下の通りです:
<h2> Thank you for joining %PORTALNAME <h2><span style='font-size:14px; font-weight: normal;'> You are receiving this e-mail because you (hopefully) created a new member account at %PORTALNAME! In order to be able to fully use your account, you will need to confirm your e-mail address, by clicking on %CONFIRMATIONLINK.<br> If your e-mail client doesn't recognize the above link, you can copy this url <b>%JUSTLINK</b> and paste it in any browser window, to confirm your account. <br><br> If it wasn't you, who opted for this registration, please ignore this message!</span> <br> <h3 style='margin-bottom: 5px;'> Your login credentials: </h3><div style='width: 100px; float: left;'> Username: </div><div style='float: left;'> %EMAIL </div><div style='clear:both;'></div><div style='width: 100px; float: left;'> Password: </div><div style='float: left;'> %PLAINPASSWORD </div><div style='clear:both;'></div>
そして、私はこのようなルックスを受け取るメッセージのソース:
Return-Path: <[email protected]>
Delivered-To: [email protected]
Received: from xxx.xxx.xxx
by xxx.xxx.xxx (Dovecot) with LMTP id wT5IIgnOKVh8fgAAhsLUGA
for <[email protected]>; Mon, 14 Nov 2016 14:45:29 +0000
Return-path: <[email protected]>
Envelope-to: [email protected]
Delivery-date: Mon, 14 Nov 2016 14:45:29 +0000
Received: from xxx.xxx.xxx ([199.191.58.218]:48854)
by xxx.xxx.xxx with esmtp (Exim 4.87)
(envelope-from <[email protected]>)
id 1c6IVl-0008M6-Bo
for [email protected]; Mon, 14 Nov 2016 14:45:29 +0000
Received: by xxx.xxx.xxx (Postfix, from userid 48)
id 7071DAA810F7; Mon, 14 Nov 2016 09:44:49 -0500 (EST)
To: [email protected]
Subject: Account confirmation
X-PHP-Originating-Script: 505:PHPMailer.php
Date: Mon, 14 Nov 2016 16:44:49 +0200
From: PortalName - Account Information <[email protected]>
Message-ID: <[email protected]>
X-Mailer: PHPMailer 5.2.14 (https://github.com/PHPMailer/PHPMailer)
MIME-Version: 1.0
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<h2> Thank you for joining PortalName <h2><span style=3D'font-size:14px; font-w=
eight: normal;'> You are receiving this e-mail because you (hopefully) crea=
ted a new member account at PortalName! In order to be able to fully use your a=
ccount, you will need to confirm your e-mail address, by clicking on <a hre=
f=3D'xxx.xxx.xxx/verify-account/xxxxxx/'> this link</a>.<br> I=
f your e-mail client doesn't recognize the above link, you can copy this ur=
l <b>xxx.xxx.xxx/verify-account/xxxxxx/</b> and paste it in an=
y browser window, to confirm your account. <br><br> If it wasn't you, who o=
pted for this registration, please ignore this message!</span> <br> <h3 sty=
le=3D'margin-bottom: 5px;'> Your login credentials: </h3><div style=3D'widt=
h: 100px; float: left;'> Username: </div><div style=3D'float: left;'> xxx.=
[email protected] </div><div style=3D'clear:both;'></div><div style=
=3D'width: 100px; float: left;'> Password: </div><div style=3D'float: left;=
'> xxxxxxxxx </div><div style=3D'clear:both;'></div>