将swiftmailer从4.1.3更新到5.4.9会导致附件被编码在正文中

时间:2018-03-24 17:36:41

标签: php swiftmailer

Kayako帮助台在尝试以名称或主题发送外国字符时总是出错,它来自swiftmailer。我决定更新swiftmailer,看看是否会修复。事情正在发挥作用(我需要做一些重命名,因为他们使用SwiftMailer_而不是Swift_所以重命名swiftmailer部分使用SwiftMailer而不是Swift,因为他们已经有了Swift类)。无论如何,当事情正在发挥作用时,问题是当附件以编码方式发送时发送的电子邮件,而outlook 2010无法看到附件中的所有原始base64编码。为什么这样做(我需要改变什么?)?谢谢!!这是我的示例消息(已修改为更改域名等):

Return-Path: <support@example.com>
Delivered-To: my-mydomain:com-common@example.com
X-Envelope-To: common@example.com
Received: (qmail 75685 invoked by uid 3002); 24 Mar 2018 16:21:24 -0000
Delivered-To: my-mydomain:com-test@example.com
Received: (qmail 75678 invoked from network); 24 Mar 2018 16:21:24 -0000
Received: from localhost (HELO server1.hosting.com) (127.0.0.1)
  by localhost with ESMTPS (XXXXXXXXXXXXXX encrypted); 24 Mar 2018 16:21:24 -0000
Received: by server1.hosting.com (Postfix, from userid 3002)
    id XXXXXXXXXX; Sat, 24 Mar 2018 12:21:24 -0400 (EDT)
To: test@example.com
Subject: [!JIJ-378-38213]: test attachments with new mail
X-PHP-Originating-Script: 3002:SimpleMailInvoker.php
Message-ID: <85813f39edb1fe7703129c308631f652@swift.generated>
Date: Sat, 24 Mar 2018 09:21:24 -0700
From: "Joe Tester." <support@example.com>
Reply-To: support@example.com
MIME-Version: 1.0
Content-Type: multipart/mixed;
 boundary="=?utf-8?Q?=5F=3D=5Fswiftmailer=5Fv4=5F1521908484=5Fe2a5856ffdce83f648b?=
 =?utf-8?Q?424876afd452c=5F=3D=5F?="
X-Priority: 3 (Normal)


--_=_swiftmailer_v4_1521908484_e2a5856ffdce83f648b424876afd452c_=_
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

<font face=3D"Verdana, Arial, Helvetica" size=3D"2">test attachments wit=
h new mail<br />
------------------------------<br />
<br />
<div style=3D"margin-left: 40px;">Ticket ID: JIJ-378-38213</div>
<div style=3D"margin-left: 40px;">URL: <a href=3D"https://www.mydom=
ain.com/kayako/staff/index.php?/Tickets/Ticket/View/31771">https://=
www.example.com/kayako/staff/index.php?/Tickets/Ticket/View/=
31771</a></div>
<div style=3D"margin-left: 40px;">Full Name: Joe Tester.</div>
<div style=3D"margin-left: 40px;">Email: <a href=3D"mailto:joetest@myd=
main.com">joetest@example.com</a></div>
<div style=3D"margin-left: 40px;">Creator: User</div>
<div style=3D"margin-left: 40px;">Department: Support</div>
<div style=3D"margin-left: 40px;">Staff (Owner): -- Unassigned --</div>
<div style=3D"margin-left: 40px;">Type: Issue</div>
<div style=3D"margin-left: 40px;">Status: Open</div>
<div style=3D"margin-left: 40px;">Priority: Normal</div>
<div style=3D"margin-left: 40px;">SLA: Default 12 Hours Plan</div>
<div style=3D"margin-left: 40px;">Template Group: Default</div>
<div style=3D"margin-left: 40px;">Created: 24 March 2018 09:21 AM</div>
<div style=3D"margin-left: 40px;">Updated: 24 March 2018 09:21 AM</div>
<div style=3D"margin-left: 40px;">Due: 26 March 2018 12:00 PM (2d 2h 39m)</=
div>
<div style=3D"margin-left: 40px;">Resolution Due: 28 March 2018 12:00 AM =
(3d 14h 39m)</div>
<br />
<br />
<br />
Let's see what happens.<br />
<br />
 <br />
<br />
<a href=3D"http://www.example.com" target=3D"_blank">http://www.=
example.com</a><br />
<br />
 <br />
<br />
<br />

<br />
<HR style=3D"margin-bottom: 6px; height: 1px; BORDER: none; color: #cfcf=
cf; background-color: #cfcfcf;" />
Staff CP:  <a href=3D"https://www.example.com/kayako/staff" tar=
get=3D"_blank">https://www.example.com/kayako/staff</a><br />
</font>

--_=_swiftmailer_v4_1521908484_e2a5856ffdce83f648b424876afd452c_=_
Content-Type: application/octet-stream; name=testpicxx.gif
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=testpicxx.gif
SNIPPED ALL THIS!
FAABCcAADeABK9ADQuAEWkAGcYAIoVALzYAOEPUlAQEAOw==

--_=_swiftmailer_v4_1521908484_e2a5856ffdce83f648b424876afd452c_=_--

1 个答案:

答案 0 :(得分:0)

所以看一下标题,我认为它必须与boundary=行中的所有废话有关,所以swiftmailer/classes/Swift/Mime/SimpleMimeEntity.php我改变了:

$this->_boundary = '_=_swiftmailer_v4_'.time().'_'.md5(getmypid().mt_rand().uniqid('', true)).'_=_';

$this->_boundary = 'swiftmailerv4'.time().'x'.md5(getmypid().mt_rand().uniqid('', true));

现在事情正在发挥作用。

但是,由于它似乎搞乱了电子邮件客户端不支持的标题字段,我想知道如果主题或来自/来自/ cc需要字符,我是否会遇到任何问题编码?我无法使用swiftmailer的V6,因为kayako不支持php7。