phpDocumentor Mail
[ class tree: Mail ] [ index: Mail ] [ all elements ]

Class: Mail_mimePart

Source Location: /lodel/scripts/PEAR/Mail/mimePart.php

Class Mail_mimePart

Class Overview

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 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.

Located in /lodel/scripts/PEAR/Mail/mimePart.php [line 94]



		
				Author(s):
		
		
		API Tags:
Filesource:  Source Code for this file

Information Tags:
Version:  $Revision: 1965 $

Properties

Methods

[ Top ]
Property Summary
string   $_body   The body of this part (not encoded)
string   $_encoded   The output of this part after being built
string   $_encoding   The encoding type of this part
array   $_headers   Headers for this part
array   $_subparts   An array of subparts

[ Top ]
Method Summary
Mail_mimePart   Mail_mimePart()   Constructor.
A   &addSubPart()   &addSubPart()
An   encode()   encode()
void   _getEncodedData()   _getEncodedData()
void   _quotedPrintableEncode()   quoteadPrintableEncode()

[ Top ]
Properties
string   $_body [line 124]

The body of this part (not encoded)


[ Top ]
string   $_encoded [line 112]

The output of this part after being built


[ Top ]
string   $_encoding [line 100]

The encoding type of this part


[ Top ]
array   $_headers [line 118]

Headers for this part


[ Top ]
array   $_subparts [line 106]

An array of subparts


[ Top ]
Methods
Constructor Mail_mimePart  [line 142]

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

Constructor.

Sets up the object.

Parameters:
$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

API Tags:
Access:  public


[ Top ]
addSubPart  [line 264]

  A &addSubPart( $body $body, $params $params  )

&addSubPart()

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

Parameters:
$body   $body:  The body of the subpart, if any.
$params   $params:  The parameters for the subpart, same as the $params argument for constructor.

API Tags:
Return:  reference to the part you just added. It is crucial if using multipart/* in your subparts that you use =& in your script when calling this function, otherwise you will not be able to add further subparts.
Access:  public


[ Top ]
encode  [line 216]

  An encode( )

encode()

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


API Tags:
Return:  associative array containing two elements, body and headers. The headers element is itself an indexed array.
Access:  public


[ Top ]
_getEncodedData  [line 280]

  void _getEncodedData( $data $data, $encoding $encoding  )

_getEncodedData()

Returns encoded data based upon encoding passed to it

Parameters:
$data   $data:  The data to encode.
$encoding   $encoding:  The encoding type to use, 7bit, base64, or quoted-printable.

API Tags:
Access:  private


[ Top ]
_quotedPrintableEncode  [line 312]

  void _quotedPrintableEncode( $input $input, [$line_max $line_max = 76]  )

quoteadPrintableEncode()

Encodes data to quoted-printable standard.

Parameters:
$input   $input:  The data to encode
$line_max   $line_max:  Optional max line length. Should not be more than 76 chars

API Tags:
Access:  private


[ Top ]

Documentation generated on Thu, 17 Apr 2008 05:07:23 +0200 by phpDocumentor 1.4.0a2