我使用PHP Zend Framework类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 Application中无法识别。在Thunderbird 3和Outlook 2007中很好用。只有在Apple Mail中,无法识别PDF附件。

在Apple Mail,Thunderbord和Outlook中,选项1可以。但是将这种结构从Zend Framework类Zend_Mail中删除会有些棘手。

这是Apple Mail中的错误,还是选项2不规范?

亲切的问候,

最佳答案

您是否尝试过指定类型?见本页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);

10-04 21:57
查看更多