2011-10-14 33 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是。 –

相关问题