Mail_mimePart

Mail_mimePart -- create multipart messages (for experienced user)

Description

Mail_mimePart enables you to manipulate and build a MIME email from the grund up. This class contains no default values or high level API functions, but you get a control about the internals of a MIME mail. Don't use this class if you are not experienced with the format and/or creating multipart MIME messages. You should take a look on Mail_mime , to check if this class already fits your needs.

Mail_mime::Mail_mimePart()

Mail_mimePart Mail_mimePart ([string $body = '' [, array $params = array()]])

Description

Returns a new instance of Mail_mimePart

Parameter

Notes

Since multipart/mixed has no real body, (the body is the subpart), the body argument can set to blank.

Mail_mime::encode()

array encode ()

Description

Encodes and returns the email. Also stores it in the encoded member variable

Return value

Mail_mime::&addSubPart()

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

Description

Adds a subpart to current MIME part and returns a reference to it

Parameter

Return value

Example

<?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';

...
?>