简体   繁体   English

Mime和Office365

[英]Mime and Office365

We are receiving corrupted emails with PDF attachments from our PHP/Zend application. 我们正在从PHP / Zend应用程序接收带有PDF附件的损坏电子邮件。 We just recently migrated to MS Office365. 我们最近才迁移到MS Office365。 MS telling us that MIME format is not supported by Office365. MS告诉我们Office365不支持MIME格式。

The emails get corrupted only when they have attachments. 电子邮件只有在具有附件时才会损坏。 Zend form emails in MIME format by default. 默认情况下,MIME格式的Zend表单电子邮件。 What are our options? 我们有什么选择? How can we send emails with PDF attachments, from PHP/Zend application through office365? 我们如何通过Office365从PHP / Zend应用程序发送带有PDF附件的电子邮件?

EDIT 1 编辑1

PHP code which sends the email: 发送电子邮件的PHP代码:

$mail = new Zend_Mail();
$mail->setFrom(Zend_Registry::get('config')->app->contact->email);
$mail->addTo($this->getUscEmail(), $this->getFirstName().' '.$this->getLastName());
$mail->addCc(Zend_Registry::get('config')->app->contact->email, 'SOWK FWS');
$mail->setSubject('Workstudy Documentation - '.$this->getFirstName().' '.$this->getLastName());
$mail->setBodyText('Hi '.$this->getFirstName().",\r\n".'Congratulations on completing your FWS Orientation!');

$file = Zend_Registry::get('config')->app->pdf_path."CertificateAndAgreement.pdf";
//load pdf from string
$pdf = Zend_Pdf::load($file);
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
$page = $pdf->pages[0];
$page->setFont($font, 12);
$page->drawText($this->getFirstName().' '.$this->getLastName(), 72, 133);
$uscId = $this->getUscId();
$page->drawText(substr($uscId, 0, 4).'-'.substr($uscId, 4, 2).'-'.substr($uscId, -4), 340, 133);
$at = $mail->createAttachment($pdf->render());
$at->filename = "CertificateAndAgreement.pdf";
$at->type        = 'application/pdf';

$file = Zend_Registry::get('config')->app->pdf_path."FWSOrientationHandouts.pdf"; //load pdf from string
$contents = file_get_contents($file);
$at2 = $mail->createAttachment($contents);   
$at2->filename = "Handouts.pdf";
$at2->type        = 'application/pdf';
$mail->send();

And this is an example of email we are getting: 这是我们收到的电子邮件的示例:

    This is a message in Mime Format.  If you see this, your mail reader does not support this format.

--_c0af0986a1041f0bc7afd728e445b8db
Content-Type: text/plain; charsetiso-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Congratulations on completing your FWS Orientation!

--_c0af0986a1041f0bc7afd728e445b8db
Content-Type: application/pdf
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename"CertificateAndAgreement.pdf"

JVBERi0xLjUNCiW1tbW1DQoxIDAgb2JqDQo8PC9UeXBlL0NhdGFsb2cvUGFnZXMgMiAwIFIv
TGFuZyhlbi1VUykgL1N0cnVjdFRyZWVSb290IDIxIDAgUi9NYXJrSW5mbzw8L01hcmtlZCB0
cnVlPj4+Pg0KZW5kb2JqDQoyIDAgb2JqDQo8PC9UeXBlL1BhZ2VzL0NvdW50IDEvS2lkc1sg
MyAwIFJdID4+DQplbmRvYmoNCjMgMCBvYmoNCjw8L1R5cGUvUGFnZS9QYXJlbnQgMiAwIFIv
UmVzb3VyY2VzPDwvRm9udDw8L0YxIDUgMCBSL0YyIDcgMCBSL0YzIDkgMCBSL0Y0IDE0IDAg
Ui9GNSAxNiAwIFIvRjYgMTggMCBSPj4vUHJvY1NldFsvUERGL1RleHQvSW1hZ2VCL0ltYWdl
Qy9JbWFnZUldID4+L01lZGlhQm94WyAwIDAgNjEyIDc5Ml0gL0NvbnRlbnRzIDQgMCBSL0dy
b3VwPDwvVHlwZS9Hcm91cC9TL1RyYW5zcGFyZW5jeS9DUy9EZXZpY2VSR0I+Pi9UYWJzL1Mv
U3RydWN0UGFyZW50cyAwPj4NCmVuZG9iag0KNCAwIG9iag0KPDwvRmlsdGVyL0ZsYXRlRGVj
b2RlL0xlbmd0aCAxMjI1NT4+DQpzdHJlYW0NCnicvZ1ZkxzHkeffacbvkA/zgF4jU3kfszKZ
rXhInKWOEaCRyaS1tQK6iOYK6IIa3YK4n378iOPvlVnV5Vk7KxkBVHd4+i8Oj/CIcM8qfvb7
...
[here comes a lot of garbage instead of PDF file]

Here is the header of this message 这是此邮件的标题

    Received: from BY2PRD0712HT001.namprd07.prod.outlook.com (10.255.246.34) by
 BL2PRD0711HT005.namprd07.prod.outlook.com (10.255.104.168) with Microsoft
 SMTP Server (TLS) id 14.16.329.3; Thu, 11 Jul 2013 17:58:15 +0000
Received: from BY2PRD0712HT003.namprd07.prod.outlook.com (10.255.246.36) by
 BY2PRD0712HT001.namprd07.prod.outlook.com (10.255.246.34) with Microsoft SMTP
 Server (TLS) id 14.16.329.3; Thu, 11 Jul 2013 17:58:14 +0000
Received: from mail39-co1-R.bigfish.com (216.32.180.180) by
 BY2PRD0712HT003.namprd07.prod.outlook.com (10.255.246.36) with Microsoft SMTP
 Server (TLS) id 14.16.329.3; Thu, 11 Jul 2013 17:58:08 +0000
Received: from mail39-co1 (localhost [127.0.0.1])   by mail39-co1-R.bigfish.com
 (Postfix) with ESMTP id 1E9AF1000A2    for <username@exchange.usc.edu>; Thu, 11
 Jul 2013 17:58:08 +0000 (UTC)
X-Forefront-Antispam-Report: CIP:128.125.137.218;KIP:(null);UIP:(null);IPV:NLI;H:msg-ironport3.usc.edu;RD:msg-ironport3.usc.edu;EFVD:NLI
X-SpamScore: 0
X-BigFish: ps0(zzzz1f42h1d77h1ee6h1de0h1fdah2073h1202h1e76h1d1ah1d2ah1fc6hzzz2fh2a8h668h839hd24h1288h12a5h12a9h12bdh12e5h137ah13b6h13eah1441h14ddh1504h1537h153bh162dh1631h1758h18b6h18e1h1946h19b5h1b0ah1d0ch1d2eh1d3fh1dc1h1dfeh1dffh1e1dh35h1155h)
Received-SPF: pass (mail39-co1: domain of usc.edu designates 128.125.137.218 as permitted sender) client-ip=128.125.137.218; envelope-from=someuser@usc.edu; helo=msg-ironport3.usc.edu ;ort3.usc.edu ;
Received: from mail39-co1 (localhost.localdomain [127.0.0.1]) by mail39-co1
 (MessageSwitch) id 1373565485428745_21893; Thu, 11 Jul 2013 17:58:05 +0000
 (UTC)
Received: from CO1EHSMHS001.bigfish.com (unknown [10.243.78.249])   by
 mail39-co1.bigfish.com (Postfix) with ESMTP id 25BEBE0062  for
 <username@exchange.usc.edu>; Thu, 11 Jul 2013 17:58:05 +0000 (UTC)
Received: from msg-ironport3.usc.edu (128.125.137.218) by
 CO1EHSMHS001.bigfish.com (10.243.66.11) with Microsoft SMTP Server (TLS) id
 14.1.225.23; Thu, 11 Jul 2013 17:57:55 +0000
X-IronPort-AV: E=Sophos;i="4.89,1045,1367996400"; 
   d="scan'208";a="240502123"
Received: from email-staff.usc.edu ([128.125.137.21])  by msg-ip3.usc.edu with
 ESMTP; 11 Jul 2013 10:55:50 -0700
MIME-Version: 1.0
Content-Disposition: inline
Content-Type: text/plain
Received: from msg-ironport2.usc.edu (msg-ironport2.usc.edu [128.125.137.216])
 by email-staff.usc.edu (Sun Java(tm) System Messaging Server 7u3-17.01 64bit
 (built Jun  8 2010)) with ESMTP id <0MPS00KPP9SN3A70@email-staff.usc.edu> for
 username@exchange.usc.edu (ORCPT username@usc.edu); Thu, 11 Jul 2013 10:55:47
 -0700 (PDT)
Authentication-results: msg-ironport2.usc.edu; dkim=neutral (message not
 signed) header.i=none
Message-ID: <45927a$14o9gj0@msg-ironport2.usc.edu>
X-IronPort-AV: E=Sophos;i="4.89,1045,1367996400";
 d="pdf'?scan'208";a="1233437287"
Received: from sowksec1.usc.edu (HELO SOWKSEC1) ([68.181.121.7]) by
 msg-ironport2.usc.edu with SMTP; Thu, 11 Jul 2013 10:55:39 -0700
Subject: Workstudy Documentation - Viktor Raskin
To: <username@usc.edu>
From: <username@usc.edu>
CC: SOWK FWS <username@usc.edu>
Date: Thu, 11 Jul 2013 10:55:39 -0700
Return-Path: someuser@usc.edu
X-MS-Exchange-Organization-SCL: -1
X-MS-Exchange-Organization-AVStamp-Mailbox: MSFTFF;1;0;0 0 0
X-MS-Exchange-Inbox-Rules-Loop: username@usc.edu
X-MS-Exchange-Organization-AuthSource:
 BY2PRD0712HT003.namprd07.prod.outlook.com
X-MS-Exchange-Organization-AuthAs: Anonymous

Well, the solution is just to add html content to the body of the email. 好吧,解决方案只是将html内容添加到电子邮件正文中。 I am not sure why Office365 is requirring both 我不确定为什么Office365要求两者

$mail->setBodyText(strip_tags($content));
$mail->setBodyHtml($content);

It is probably can be changed on the server side. 它可能可以在服务器端更改。 MS support are not aware about this fact. MS支持人员不了解此事实。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM