我用PHP Zend框架类Zend_Mail构建了一个电子邮件。有一个文本部分和一个html部分与相关的内联图像。我也想附上一个pdf文件。
我的问题是关于时间结构的。有两个选项:选项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在Apple Mail应用程序中不被识别。在Thunderbird 3和Outlook 2007中都没问题。只有在Apple Mail中不能识别pdf附件。
选项1在Apple Mail, thunderboard和Outlook中是可以的。但是从Zend框架类Zend_Mail中取出这个结构会有点棘手。
这是Apple Mail的Bug还是选项2不规范?
亲切的问候,sn
是否尝试指定类型?请看此页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);
这两个选项都违反了RFC822,标题行必须从该行的第一个字符开始;这是很重要的,因为当第一个字符是空白时,会触发折叠。
的例子:
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和这里提供的链接:邮件头区分大小写吗?