2013-07-10 34 views
0

我們從PHP/Zend應用程序接收到帶有PDF附件的損壞電子郵件。我們剛剛遷移到MS Office365。 MS告訴我們Office365不支持MIME格式。Mime和Office365

電子郵件只有在有附件時纔會損壞。 Zend在默認情況下以MIME格式形成電子郵件。我們有什麼選擇?我們如何通過office365從PHP/Zend應用程序發送帶PDF附件的電子郵件?

編輯1

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(); 

這就是我們得到的電子郵件的一個例子:

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] 

這裏是此消息的標題

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 <[email protected]>; 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; [email protected]; 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 
<[email protected]>; 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 <[email protected]> for 
[email protected] (ORCPT [email protected]); 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: <[email protected]> 
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: <[email protected]> 
From: <[email protected]> 
CC: SOWK FWS <[email protected]> 
Date: Thu, 11 Jul 2013 10:55:39 -0700 
Return-Path: [email protected] 
X-MS-Exchange-Organization-SCL: -1 
X-MS-Exchange-Organization-AVStamp-Mailbox: MSFTFF;1;0;0 0 0 
X-MS-Exchange-Inbox-Rules-Loop: [email protected] 
X-MS-Exchange-Organization-AuthSource: 
BY2PRD0712HT003.namprd07.prod.outlook.com 
X-MS-Exchange-Organization-AuthAs: Anonymous 
+2

'MS告訴我們Office365不支持MIME格式 - 這是不對的。如果沒有MIME支持,它將會或多或少地失效。很遠,*很可能你的郵件不正確* MIME格式。 – DaveRandom

+0

我對它很陌生,但也懷疑它不可能是真的。但是,這是在我們遷移到Office365之後開始的。 MS支持人員不能告訴我們我們的消息是如何改變的。我發佈了代碼和電子郵件示例。謝謝。 – vlr

+0

* charsetiso-8859-1 *此處缺少一個等號。也許還有更多問題。請發佈包含郵件標題的完整郵件。 – mkl

回答

0

那麼,解決方案只是添加HTML內容的電子郵件的正文。我不知道爲什麼Office365需要這兩個

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

它可能是可以在服務器端進行更改。 MS支持不知道這個事實。