Class src_mail_MIMEPart

Description

Raw mime encoding class

What is it? This class enables you to manipulate and build a mime email from the ground up.

Why use this instead of mime.php? mime.php is a userfriendly api to this class for people who aren't interested in the internals of mime mail. This class however allows full control over the email.

Eg.

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

$params['content_type'] = 'multipart/mixed'; $email = new src_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';

Further examples are available at http://www.phpguru.org

TODO:

  • Set encode() to return the $obj->encoded if encode() has already been run. Unless a flag is passed to specifically re-build the message.
Short description of class src_foundation_admin_ADMINARCHIV

  • version: $Revision: 1.3 $
  • copyright: Copyright (c) 2005
  • author: Richard Heyes <richard@phpguru.org>
  • access: public

Located in /src/mail/class.mimePart.php (line 97)


	
			
Method Summary
src_mail_MIMEPart __construct ([$body $body = ''], [$params $params = array ()])
A addSubPart ($body $body, $params $params)
An encode ()
Methods
Constructor __construct (line 144)

Constructor.

Sets up the object.

  • access: public
src_mail_MIMEPart __construct ([$body $body = ''], [$params $params = array ()])
  • $body $body: - The body of the mime part if any.
  • $params $params: - An associative array of parameters: content_type - The content type for this part eg multipart/mixed encoding - The encoding to use, 7bit, 8bit, base64, or quoted-printable cid - Content ID to apply disposition - Content disposition, inline or attachment dfilename - Optional filename parameter for content disposition description - Content description charset - Character set to use
addSubPart (line 254)

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

  • return: reference to the part you just added.
  • access: public
A addSubPart ($body $body, $params $params)
  • $body $body: The body of the subpart, if any.
  • $params $params: The parameters for the subpart, same as the $params argument for constructor.
encode (line 214)

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

  • return: associative array containing two elements, body and headers. The headers element is itself an indexed array.
  • access: public
An encode ()

Documentation generated on Sat, 24 Mar 2007 09:59:39 +0100 by phpDocumentor 1.3.1