3

PHP Zend Framework Class Zend_Mailを使用して電子メールを作成します。関連するインライン画像を含む 1 つのテキスト部分と 1 つの html 部分があります。pdfファイルも1つ添付したいです。

私の質問は、mime 構造についてです。次の 2 つのオプションが可能です。

オプション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、Thunderbord、および Outlook では問題ありません。しかし、この構造を Zend Framework クラスZend_Mailから取り出すのは少し難しいでしょう。

これは Apple Mail のバグですか、それともオプション 2 は規範的ではありませんか?

よろしく、スン

4

2 に答える 2

0

タイプを指定してみましたか?このページを参照してください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);
于 2011-10-14T15:47:17.830 に答える
-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およびここで提供されるリンク:電子メール ヘッダーは大文字と小文字を区別しますか?

于 2011-10-25T22:09:51.917 に答える