| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- Reviewed: no -->
- <!-- EN-Revision: 24249 -->
- <sect1 id="zend.mail.attachments">
- <title>ファイルの添付</title>
- <para>
- メールにファイルを添付するには <methodname>createAttachment()</methodname> メソッドを使用します。
- <classname>Zend_Mail</classname> のデフォルト設定では、添付ファイルは
- base64 エンコードされたバイナリオブジェクト (<property>application/octet-stream</property>)
- として添付されます。この挙動を変更するには、
- <methodname>createAttachment()</methodname> に追加のパラメータを指定します。
- </para>
- <example id="zend.mail.attachments.example-1">
- <title>ファイルを添付したメール</title>
- <programlisting language="php"><![CDATA[
- $mail = new Zend_Mail();
- // メッセージを作成します...
- $mail->createAttachment($someBinaryString);
- $mail->createAttachment($myImage,
- 'image/gif',
- Zend_Mime::DISPOSITION_INLINE,
- Zend_Mime::ENCODING_BASE64);
- ]]></programlisting>
- </example>
- <para>
- 添付ファイル用の <acronym>MIME</acronym> パートを細かく制御するには、
- <methodname>createAttachment()</methodname> の返す値を使用してその属性を変更します。
- <methodname>createAttachment()</methodname> メソッドの返す値は
- <classname>Zend_Mime_Part</classname> オブジェクトです。
- </para>
- <programlisting language="php"><![CDATA[
- $mail = new Zend_Mail();
- $at = $mail->createAttachment($myImage);
- $at->type = 'image/gif';
- $at->disposition = Zend_Mime::DISPOSITION_INLINE;
- $at->encoding = Zend_Mime::ENCODING_BASE64;
- $at->filename = 'test.gif';
- $mail->send();
- ]]></programlisting>
- <para>
- もうひとつの方法は、<classname>Zend_Mime_Part</classname> のインスタンスを作成して
- それを <methodname>addAttachment()</methodname> で追加するものです。
- </para>
- <programlisting language="php"><![CDATA[
- $mail = new Zend_Mail();
- $at = new Zend_Mime_Part($myImage);
- $at->type = 'image/gif';
- $at->disposition = Zend_Mime::DISPOSITION_INLINE;
- $at->encoding = Zend_Mime::ENCODING_BASE64;
- $at->filename = 'test.gif';
- $mail->addAttachment($at);
- $mail->send();
- ]]></programlisting>
- </sect1>
- <!--
- vim:se ts=4 sw=4 et:
- -->
|