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

Class: Mail_mime

Source Location: /Mail_Mime-1.8.9/Mail/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 95]
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 175]

void Mail_mime( [mixed $params = array()])

Constructor function
  • Access: public

Parameters:

mixed   $params     Build parameters that change the way the email is built. Should be an associative array. See $_build_params.

[ Top ]

addAttachment   [line 397]

mixed addAttachment( string $file, [string $c_type = 'application/octet-stream'], [string $name = ''], [bool $isfile = true], [string $encoding = 'base64'], [string $disposition = 'attachment'], [string $charset = ''], [string $language = ''], [string $location = ''], [string $n_encoding = null], [string $f_encoding = null], [string $description = ''], [string $h_charset = null], [array $add_headers = array()])

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 of attachment's content.
string   $language     The language of the attachment
string   $location     The RFC 2557.4 location of the attachment
string   $n_encoding     Encoding of the attachment's name in Content-Type By default filenames are encoded using RFC2231 method Here you can set RFC2047 encoding (quoted-printable or base64) instead
string   $f_encoding     Encoding of the attachment's filename in Content-Disposition header.
string   $description     Content-Description header
string   $h_charset     The character set of the headers e.g. filename If not specified, $charset will be used
array   $add_headers     Additional part headers. Array keys can be in form of <header_name>:<parameter_name>

[ Top ]

addBcc   [line 1237]

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 1219]

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 326]

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

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 used if $file is the image data.
bool   $isfile     Whether $file is a filename or not. Defaults to true
string   $content_id     Desired Content-ID of MIME part Defaults to generated unique ID

[ Top ]

addTo   [line 1201]

void addTo( string $email)

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

Parameters:

string   $email     The email direction to add

[ Top ]

encodeHeader   [line 1313]

string encodeHeader( string $name, string $value, string $charset, string $encoding)

Encodes a header as per RFC2047
  • Return: Encoded header data (without a name)
  • Since: 1.5.3
  • Access: public

Parameters:

string   $name     The header name
string   $value     The header data to encode
string   $charset     Character set name
string   $encoding     Encoding name (base64 or quoted-printable)

[ Top ]

encodeRecipients   [line 1259]

string encodeRecipients( string $recipients)

Since the PHP send function requires you to specify 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 838]

mixed get( [array $params = null], [resource $filename = null], [boolean $skip_head = false])

Builds the multipart message from the list ($this->_parts) and returns the mime content.
  • Return: The MIME message content string, null or PEAR error object
  • Access: public

Parameters:

array   $params     Build parameters that change the way the email is built. Should be associative. See $_build_params.
resource   $filename     Output file where to save the message instead of returning it
boolean   $skip_head     True if you want to return/save only the message without headers

[ Top ]

getHTMLBody   [line 306]

string getHTMLBody( )

Get message HTML body
  • Return: HTML body
  • Since: 1.6.0
  • Access: public

[ Top ]

getMessage   [line 710]

mixed getMessage( [string $separation = null], [array $params = null], [array $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 $headers parameter!

  • Return: The complete e-mail or PEAR error object
  • Access: public

Parameters:

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

[ Top ]

getMessageBody   [line 737]

mixed getMessageBody( [array $params = null])

Returns the complete e-mail body, ready to send using an alternative mail delivery method.
  • Return: The e-mail body or PEAR error object
  • Since: 1.6.0
  • Access: public

Parameters:

array   $params     The Build parameters passed to the get() method. See get() for more info.

[ Top ]

getParam   [line 216]

mixed getParam( string $name)

Get build parameter value
  • Return: Parameter value
  • Since: 1.6.0
  • Access: public

Parameters:

string   $name     Parameter name

[ Top ]

getTXTBody   [line 268]

string getTXTBody( )

Get message text body
  • Return: Text body
  • Since: 1.6.0
  • Access: public

[ Top ]

headers   [line 1040]

array headers( [array $xtra_headers = null], [bool $overwrite = false], [bool $skip_content = 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) (Don't set Content-Type for multipart messages here!)
bool   $overwrite     Overwrite already existing headers.
bool   $skip_content     Don't return content headers: Content-Type, Content-Disposition and Content-Transfer-Encoding

[ Top ]

saveMessage   [line 757]

mixed saveMessage( string $filename, [array $params = null], [array $headers = null], [bool $overwrite = false])

Writes (appends) the complete e-mail into file.
  • Return: True or PEAR error object
  • Since: 1.6.0
  • Access: public

Parameters:

string   $filename     Output file location
array   $params     The Build parameters passed to the get() method. See get() for more info.
array   $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 ]

saveMessageBody   [line 802]

mixed saveMessageBody( string $filename, [array $params = null])

Writes (appends) the complete e-mail body into file.
  • Return: True or PEAR error object
  • Since: 1.6.0
  • Access: public

Parameters:

string   $filename     Output file location
array   $params     The Build parameters passed to the get() method. See get() for more info.

[ Top ]

setContentType   [line 1130]

void setContentType( string $type, [array $params = array()])

Sets message Content-Type header.

Use it to build messages with various content-types e.g. miltipart/raport not supported by _contentHeaders() function.

  • Since: 1.7.0
  • Access: public

Parameters:

string   $type     Type name
array   $params     Hash array of header parameters

[ Top ]

setFrom   [line 1187]

void setFrom( string $email)

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

Parameters:

string   $email     The email address to use

[ Top ]

setHTMLBody   [line 284]

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 ]

setParam   [line 202]

void setParam( string $name, string $value)

Set build parameter value
  • Since: 1.6.0
  • Access: public

Parameters:

string   $name     Parameter name
string   $value     Parameter value

[ Top ]

setSubject   [line 1174]

void setSubject( string $subject)

Sets the Subject header
  • Access: public

Parameters:

string   $subject     String to set the subject to.

[ Top ]

setTXTBody   [line 238]

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 1090]

string txtHeaders( [array $xtra_headers = null], [bool $overwrite = false], [bool $skip_content = 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) (Don't set Content-Type for multipart messages here!)
bool   $overwrite     Overwrite the existing headers with new.
bool   $skip_content     Don't return content headers: Content-Type, Content-Disposition and Content-Transfer-Encoding

[ Top ]


Documentation generated on Wed, 14 May 2014 10:00:09 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.