Mail_Mime
[ class tree: Mail_Mime ] [ index: Mail_Mime ] [ all elements ]

Class: Mail_mime

Source Location: /Mail_Mime-1.4.0a1/mime.php

Class Overview


The Mail_Mime class provides an OO interface to create MIME enabled email messages. This way you can create emails that contain plain-text bodies, HTML bodies, attachments, inline images and specific headers.


Author(s):

Version:

  • Release: @package_version@

Copyright:

  • 2003-2006 PEAR <pear-group@php.net>

Methods


Inherited Variables

Inherited Methods


Class Details

[line 93]
The Mail_Mime class provides an OO interface to create MIME enabled email messages. This way you can create emails that contain plain-text bodies, HTML bodies, attachments, inline images and specific headers.


[ Top ]


Method Detail

Mail_mime (Constructor)   [line 177]

void Mail_mime( [string $crlf = "\r\n"])

Constructor function.
  • Access: public

Parameters:

string   $crlf     what type of linebreak to use. Defaults to "\r\n"

[ Top ]

addAttachment   [line 321]

mixed addAttachment( string $file, [string $c_type = 'application/octet-stream'], [string $name = ''], [bool $isfile = true], [string $encoding = 'base64'], [string $disposition = 'attachment'], [string $charset = ''])

Adds a file to the list of attachments.
  • Return: true on success or PEAR_Error object
  • Access: public

Parameters:

string   $file     The file name of the file to attach OR the file contents itself
string   $c_type     The content type
string   $name     The filename of the attachment Only use if $file is the contents
bool   $isfile     Whether $file is a filename or not Defaults to true
string   $encoding     The type of encoding to use. Defaults to base64. Possible values: 7bit, 8bit, base64, or quoted-printable.
string   $disposition     The content-disposition of this file Defaults to attachment. Possible values: attachment, inline.
string   $charset     The character set used in the filename of this attachment.

[ Top ]

addBcc   [line 818]

void addBcc( string $email)

Add an email to the Bcc (blank carbon copy) header (multiple calls to this method are allowed)
  • Access: public

Parameters:

string   $email     The email direction to add

[ Top ]

addCc   [line 802]

void addCc( string $email)

Add an email to the Cc (carbon copy) header (multiple calls to this method are allowed)
  • Access: public

Parameters:

string   $email     The email direction to add

[ Top ]

addHTMLImage   [line 277]

bool addHTMLImage( string $file, [string $c_type = 'application/octet-stream'], [string $name = ''], [bool $isfile = true])

Adds an image to the list of embedded images.
  • Return: true on success
  • Access: public

Parameters:

string   $file     the image file name OR image data itself
string   $c_type     the content type
string   $name     the filename of the image. Only use if $file is the image data.
bool   $isfile     whether $file is a filename or not. Defaults to true

[ Top ]

encodeRecipients   [line 839]

string encodeRecipients( string $recipients)

Since the PHP send function requires you to specifiy recipients (To: header) separately from the other headers, the To: header is not properly encoded.

To fix this, you can use this public method to encode your recipients before sending to the send function

  • Return: Encoded data
  • Access: public

Parameters:

string   $recipients     A comma-delimited list of recipients

[ Top ]

get   [line 601]

string &get( [array $build_params = null])

Builds the multipart message from the list ($this->_parts) and returns the mime content.
  • Return: The mime content
  • Access: public

Parameters:

array   $build_params     Build parameters that change the way the email is built. Should be associative. Can contain: head_encoding - What encoding to use for the headers. Options: quoted-printable or base64 Default is quoted-printable text_encoding - What encoding to use for plain text Options: 7bit, 8bit, base64, or quoted-printable Default is 7bit html_encoding - What encoding to use for html Options: 7bit, 8bit, base64, or quoted-printable Default is quoted-printable 7bit_wrap - Number of characters before text is wrapped in 7bit encoding Default is 998 html_charset - The character set to use for html. Default is iso-8859-1 text_charset - The character set to use for text. Default is iso-8859-1 head_charset - The character set to use for headers. Default is iso-8859-1

[ Top ]

getMessage   [line 561]

string getMessage( [string $separation = null], [array $build_params = null], [array $xtra_headers = null], [bool $overwrite = false])

Returns the complete e-mail, ready to send using an alternative

mail delivery method. Note that only the mailpart that is made with Mail_Mime is created. This means that, YOU WILL HAVE NO TO: HEADERS UNLESS YOU SET IT YOURSELF using the $xtra_headers parameter!

  • Return: The complete e-mail.
  • Access: public

Parameters:

string   $separation     The separation etween these two parts.
array   $build_params     The Build parameters passed to the &get() function. See &get for more info.
array   $xtra_headers     The extra headers that should be passed to the &headers() function. See that function for more info.
bool   $overwrite     Overwrite the existing headers with new.

[ Top ]

headers   [line 735]

array &headers( [array $xtra_headers = null], [bool $overwrite = false])

Returns an array with the headers needed to prepend to the email (MIME-Version and Content-Type). Format of argument is: $array['header-name'] = 'header-value';
  • Return: Assoc array with the mime headers
  • Access: public

Parameters:

array   $xtra_headers     Assoc array with any extra headers. Optional.
bool   $overwrite     Overwrite already existing headers.

[ Top ]

setFrom   [line 790]

void setFrom( string $email)

Set an email to the From (the sender) header
  • Access: public

Parameters:

string   $email     The email direction to add

[ Top ]

setHTMLBody   [line 250]

bool setHTMLBody( string $data, [bool $isfile = false])

Adds a html part to the mail.
  • Return: true on success
  • Access: public

Parameters:

string   $data     either a string or the file name with the contents
bool   $isfile     a flag that determines whether $data is a filename, or a string(false, default)

[ Top ]

setSubject   [line 779]

void setSubject( string $subject)

Sets the Subject header

Parameters:

string   $subject     String to set the subject to access public

[ Top ]

setTXTBody   [line 218]

mixed setTXTBody( string $data, [bool $isfile = false], [bool $append = false])

Accessor function to set the body text. Body text is used if it's not an html mail being sent or else is used to fill the text/plain part that emails clients who don't support html should show.
  • Return: true on success or PEAR_Error object
  • Access: public

Parameters:

string   $data     Either a string or the file name with the contents
bool   $isfile     If true the first param should be treated as a file name, else as a string (default)
bool   $append     If true the text or file is appended to the existing body, else the old body is overwritten

[ Top ]

txtHeaders   [line 763]

string txtHeaders( [array $xtra_headers = null], [bool $overwrite = false])

Get the text version of the headers (usefull if you want to use the PHP mail() function)
  • Return: Plain text headers
  • Access: public

Parameters:

array   $xtra_headers     Assoc array with any extra headers. Optional.
bool   $overwrite     Overwrite the existing heaers with new.

[ Top ]


Documentation generated on Thu, 08 Mar 2007 12:30:11 -0500 by phpDocumentor 1.3.0. PEAR Logo Copyright © PHP Group 2004.