Mail_mimePart::addsubpart()

Mail_mimePart::addsubpart() -- MIMEパートにサブパートを追加する

概要

require_once 'Mail/mimePart.php';

resource &addSubPart (string $body, array $params)

説明

現在のMIMEパートにサブパートを加え、そのリファレンスを返します。

パラメータ

返り値

resource - 追加されたパートのリファレンスを返します。

注意

この関数は、スタティックにコールする ことはできません。

例 45-1Add two attachments to a mail


<?php    
include 'Mail/mimePart.php';

...

$params['content_type'] = 'multipart/mixed';
$email = new Mail_mimePart('', $params);

// Here we add a text part to the multipart we have
// already. Assume $body contains plain text.

$params['content_type'] = 'text/plain';
$params['encoding']     = '7bit';
$text = $email->addSubPart($body, $params);

// Now add an attachment. Assume $attach is
// the contents of the attachment

$params['content_type'] = 'application/zip';
$params['encoding']     = 'base64';
$params['disposition']  = 'attachment';
$params['dfilename']    = 'example.zip';
$attach =& $email->addSubPart($body, $params);

// Now build the email. Note that the encode
// function returns an associative array containing two
// elements, body and headers. You will need to add extra
// headers, (eg. Mime-Version) before sending.

$email = $message->encode();
$email['headers']['Mime-Version'] = '1.0';

...
?>