3

Zend を使用してメールを送信したいのですが、インライン画像がほとんどなく、PDF ファイルが添付されている場合、メールのコードは次のようになります。

From - Wed Apr 18 12:09:29 2012

[...]

Content-Type: multipart/mixed; boundary=mixed6455A4FA01BD9CFD334A87E206713ED8

[...]

--mixed6455A4FA01BD9CFD334A87E206713ED8
Content-Type: multipart/related; boundary=related6455A4FA01BD9CFD334A87E206713ED8

--related6455A4FA01BD9CFD334A87E206713ED8
Content-Type: multipart/alternative; boundary=alternative6455A4FA01BD9CFD334A87E206713ED8

--alternative6455A4FA01BD9CFD334A87E206713ED8
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

Email as plain text

best regards

--alternative6455A4FA01BD9CFD334A87E206713ED8
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

Email as <b>html</b><br />

<img src = 'cid:dvb_small.jpg' border = '0'/><br /><br/ >

best regards

<img src = 'cid:signature.gif' border = '0'/>

--alternative6455A4FA01BD9CFD334A87E206713ED8--

--related6455A4FA01BD9CFD334A87E206713ED8
Content-Type: image/jpeg
Content-Transfer-Encoding: base64
Content-ID: <dvb_small.jpg>
Content-Disposition: inline

[IMAGE CONTENT]

--related6455A4FA01BD9CFD334A87E206713ED8
Content-Type: image/gif
Content-Transfer-Encoding: base64
Content-ID: <signature.gif>
Content-Disposition: inline

[IMAGE CONTENT]

--related6455A4FA01BD9CFD334A87E206713ED8--

--mixed6455A4FA01BD9CFD334A87E206713ED8
Content-Type: application/octetstream; name="invoice_7293.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="invoice_7293.pdf"

[PDF CONTENT]

--mixed6455A4FA01BD9CFD334A87E206713ED8--

Zend_Mail を使用してそのようなコードを取得する方法はありますか? 私が今していることは次のとおりです。

$mail = new Zend_Mail;

[...]

//Adding inline images
$att = $mail->createAttachment(file_get_contents($filePath));
$att->type = $fileType['mime'];
$att->disposition = Zend_Mime::DISPOSITION_INLINE;
$att->encoding = Zend_Mime::ENCODING_BASE64;
$att->filename = $fileName;
$att->id = md5($att->filename);

//Adding PDF file
$invoiceAt = $mail->createAttachment(file_get_contents($invoicePdf));
$invoiceAt->type = 'application/octetstream';
$invoiceAt->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
$invoiceAt->encoding = Zend_Mime::ENCODING_BASE64;
$invoiceAt->filename    = 'invoice_' . $id . '.pdf';

最後に、適切なメール コンテンツ タイプを設定します。私が使用する場合:

$this->setType(Zend_Mime::MULTIPART_MIXED);

インライン ファイルは表示されず、電子メールに添付されます。

私がこれを行う場合:

$this->setType(Zend_Mime::MULTIPART_RELATED);

インライン ファイルは正しく表示されますが、pdf の添付ファイルは表示されません (そこにあり、開くことはできますが、Thunderbird では、メールをクリックした後にのみ添付ファイルの記号が表示されます)。他のメールクライアントにも問題があると思います。

その場合、生成された電子メール コードは次のようになります。

From - Wed May 02 15:12:18 2012

[...]

Content-Type: multipart/related;
 boundary="=_c3a05d0d4a6abdbfcb3fc03ac8abf402"
Content-Transfer-Encoding: quoted-printable

[...]

--=_c3a05d0d4a6abdbfcb3fc03ac8abf402
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

[HTML]

--=_c3a05d0d4a6abdbfcb3fc03ac8abf402
Content-Type: application/octetstream
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="invoice_123.pdf"

[PDF_CONTENT]

--=_c3a05d0d4a6abdbfcb3fc03ac8abf402
Content-Type: image/jpeg
Content-Transfer-Encoding: base64
Content-ID: <e783669dda40eced6adef6cd056d9887>
Content-Disposition: inline; filename="dvb_logo.jpg"

[IMAGE CONTENT]

--=_c3a05d0d4a6abdbfcb3fc03ac8abf402
Content-Type: 
Content-Transfer-Encoding: base64
Content-ID: <0c6120573af00f1160ee7049be5835c3>
Content-Disposition: inline; filename="signature.gif"

[IMAGE CONTENT]

--=_c3a05d0d4a6abdbfcb3fc03ac8abf402--

それで、私の質問の一番上にあるような電子メールコードをZendで生成する方法はありますか?

4

0 に答える 0