【问题标题】:MIME "multipart/related" Structure and Apple Mail. Is it a Bug?MIME“多部分/相关”结构和 Apple Mail。它是一个错误吗?
【发布时间】:2011-12-07 16:36:57
【问题描述】:

我用 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 构建,但 Apple Mail Application 无法识别 pdf。在 Thunderbird 3 和 Outlook 2007 中没问题。只有在 Apple Mail 中 PDF 附件无法识别。

选项 1 在 Apple Mail、Thunderbord 和 Outlook 中是可以的。但是从 Zend 框架类 Zend_Mail 中获取这个结构会有点棘手。

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

亲切的问候, sn

【问题讨论】:

    标签: zend-framework mime email-attachments zend-mail apple-mail


    【解决方案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?

    【讨论】:

    • 你完全没有抓住重点。他并不是说标题前面有空格,而是在询问结构(嵌入和子嵌入)是否正确。另外,他并没有创建实际的边界、标题等。Zend 是。
    【解决方案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);
    

    【讨论】:

    • 请注意,我没有测试它是否适用于 Apple Mail,我确定它适用于 Thunderbird 3+
    猜你喜欢
    • 2018-12-27
    • 1970-01-01
    • 1970-01-01
    • 2016-12-24
    • 1970-01-01
    • 1970-01-01
    • 2021-05-18
    • 2016-12-14
    • 1970-01-01
    相关资源
    最近更新 更多