MIME“多部分/相关”结构和Apple Mail。这是一个错误吗?

发布于 2024-12-10 00:34:31 字数 1093 浏览 0 评论 0原文

我使用 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 应用程序无法识别 pdf。在 Thunderbird 3 和 Outlook 2007 中一切正常。只有在 Apple Mail 中,PDF 附件无法识别。

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

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

亲切的问候, 锡

I build a E-Mail with PHP Zend Framework Class Zend_Mail. There is one text- and one html-part with related inline-images. I want to attach one pdf-file too.

My question is about the mime-structure. Two options are possible:

option 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 

option 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

option 2 is built by Zend_Mail, but the pdf is not recognized at Apple Mail Application. It's fine in Thunderbird 3 and Outlook 2007. Only in Apple Mail the PDF-Attachment isn't recognized.

option 1 is ok in Apple Mail, Thunderbord and Outlook. But it would be a little bit tricky to get this structure out of the Zend Framework Class Zend_Mail.

Is this a Bug in Apple Mail or is option 2 not normative?

kind regards,
sn

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

握住你手 2024-12-17 00:34:31

您是否尝试过指定类型?请参阅此页面 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);

Have you tryied specifying the type ? see this page http://framework.zend.com/manual/en/zend.mail.attachments.html

i use this

    $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);
追星践月 2024-12-17 00:34:31

这两个选项都违反了 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--

nested-portion 的一部分将包含 PDF 附件。

参考:
http://www.faqs.org/rfcs/rfc2822.html 和链接此处提供:电子邮件标头是否大小写敏感吗?

Both options are violations of RFC822, the header-lines MUST start on the first character of their line; this is important because hearer-folding is triggered by that first character being whitespace SP (#32) or HT (#09), IIRC.

Example:

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

and

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

are exactly equivalent.

The proper way to do what you're (apparently) attempting is by using the boundary attribute is something like this:

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--

One of the parts of nested-portion would contain the PDF-attachment.

Ref:
http://www.faqs.org/rfcs/rfc2822.html and the links provided here: Are email headers case sensitive?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文