2011-10-14 43 views
3

我使用PHP Zend Framework類構建電子郵件Zend_Mail。有一個文本和一個HTML部分與相關的內聯圖像。我也想附上一個pdf文件。MIME「multipart/related」結構和Apple Mail。它是一個錯誤嗎?

我的問題是關於mime結構。有兩個選項:

選項1:

Content-Type: multipart/mixed 
    Content-Type: multipart/alternative 
    Content-Type: text/plain; charset=UTF-8  
    Content-Type: multipart/related 
     Content-Type: text/html; charset=UTF-8 
     Content-Type: image/jpeg 
     Content-Type: image/jpeg 
     Content-Type: image/png 
    Content-Type: application/pdf 

選項2:

Content-Type: multipart/related; 
    Content-Type: multipart/alternative; 
    Content-Type: text/plain; charset=utf-8 
    Content-Type: text/html; charset=utf-8 
    Content-Type: image/jpeg 
    Content-Type: image/jpeg 
    Content-Type: image/png 
    Content-Type: application/pdf 

選項2通過使用Zend_Mail建成,但PDF是不是蘋果郵件應用程序的認可。在Thunderbird 3和Outlook 2007中沒問題。只有在Apple Mail中,PDF-Attachment無法識別。

選項1在Apple Mail,Thunderbord和Outlook中可以使用。但是將這個結構從Zend框架類Zend_Mail中解放出來會有點棘手。

這是Apple Mail中的錯誤還是選項2不規範?

親切的問候, SN

回答

0

你有tryied指定類型?看到這個頁面http://framework.zend.com/manual/en/zend.mail.attachments.html

我用這個

$obj_MailAttachment = new Zend_Mime_Part($allegato); 
    $obj_MailAttachment->type = 'application/pdf'; 
    $obj_MailAttachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT; 
    $obj_MailAttachment->encoding = Zend_Mime::ENCODING_BASE64; 
    $obj_MailAttachment->filename = 'ordine'.$ordine['numero'].'.pdf'; 

... 

$mail->addAttachment($obj_MailAttachment); 
+0

需要注意的是,如果它與蘋果Mail一起工作我沒有測試,我肯定知道它的工作原理與雷鳥3+ – max4ever

-1

兩個選項是違反RFC822的,首標線必須開始對他們行的第一個字符;這很重要,因爲聽者摺疊是由第一個字符爲空格SP(#32)或HT(#09),IIRC觸發的。

實施例:

Content-Type: text/html; charset=UTF-8 

Content-Type: text/html; 
    charset=UTF-8 

是完全等價的。

正確的方式做你在做什麼(顯然)試圖通過使用邊界屬性是這樣的:

Content-Type: multipart/mixed; boundary="1610edf3f7626f0847a5e75c55287644" 
OTHER-HEADERS 
--1610edf3f7626f0847a5e75c55287644 
Content-Type: multipart/mixed; boundary="embedded_boundary" 
OTHER-HEADERS 
--embedded_boundary 
NESTED-MESSAGE-GOES-HERE 
--embedded_boundary-- 
--1610edf3f7626f0847a5e75c55287644-- 

一個嵌套部分的零件將包含PDF-附件。

編號: http://www.faqs.org/rfcs/rfc2822.html這裏提供的鏈接:Are email headers case sensitive?

+0

你完全錯了。他並不是說標題前面出現空格,而是問結構(嵌入和嵌入)是否正確。另外,他沒有創建實際的邊界,頭文件等。Zend是。 –

相關問題