Mail_mimePart::addsubpart()

Mail_mimePart::addsubpart() – add sub part to a MIME part

Synopsis

require_once 'Mail/mimePart.php';

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

Description

Adds a sub part to the current MIME part and returns a reference to it

Parameter

  • string - the body of the sub part

  • array - the parameter for the sub part. See constructor for the possible values.

Return value

resource - a reference to the added part

Note

This function can not be called statically.

Example

Add 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 $contents is
// the contents of the attachment

$params['content_type'] = 'application/zip';
$params['encoding']     = 'base64';
$params['disposition']  = 'attachment';
$params['dfilename']    = 'example.zip';
$attach =& $email->addSubPart($contents$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 $email->encode();
$email['headers']['Mime-Version'] = '1.0';

...
?>
constructor (Previous) encode a mail (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.