\Horde_Mime_Mail

The Horde_Mime_Mail:: class wraps around the various MIME library classes to provide a simple interface for creating and sending MIME messages.

All content has to be passed UTF-8 encoded. The charset parameters is used for the generated message only.

Summary

Methods
Properties
Constants
__construct()
addHeaders()
addHeader()
addHeaderOb()
removeHeader()
setBody()
setHtmlBody()
addPart()
addMimePart()
setBasePart()
addAttachment()
removePart()
clearParts()
addRecipients()
removeRecipients()
clearRecipients()
send()
getRaw()
getBasePart()
No public properties found
No constants found
No protected methods found
$_headers
$_base
$_body
$_htmlBody
$_recipients
$_bcc
$_parts
$_mailer_driver
$_charset
$_mailer_params
N/A
No private methods found
No private properties found
N/A

Properties

$_htmlBody

$_htmlBody : \Horde_Mime_Part

The main HTML body part.

Type

\Horde_Mime_Part

$_recipients

$_recipients : \Horde_Mail_Rfc822_List

The message recipients.

Type

\Horde_Mail_Rfc822_List

$_bcc

$_bcc : string

Bcc recipients.

Type

string

$_parts

$_parts : array

All MIME parts except the main body part.

Type

array

$_mailer_driver

$_mailer_driver : string

The Mail driver name.

Type

string

$_charset

$_charset : string

The charset to use for the message.

Type

string

$_mailer_params

$_mailer_params : array

The Mail driver parameters.

Type

array

Methods

__construct()

__construct(array  $params = array()) 

Constructor.

Parameters

array $params

A hash with basic message information. 'charset' is the character set of the message. 'body' is the message body. All other parameters are assumed to be message headers.

Throws

\Horde_Mime_Exception

addHeaders()

addHeaders(  $headers = array()) 

Adds several message headers at once.

Parameters

$headers

Throws

\Horde_Mime_Exception

addHeader()

addHeader(string  $header, string  $value, boolean  $overwrite = null) 

Adds a message header.

Parameters

string $header

The header name.

string $value

The header value.

boolean $overwrite

If true, an existing header of the same name is being overwritten; if false, multiple headers are added; if null, the correct behaviour is automatically chosen depending on the header name.

Throws

\Horde_Mime_Exception

addHeaderOb()

addHeaderOb(\Horde_Mime_Headers_Element  $ob) 

Add a Horde_Mime_Headers_Element object to the current header list.

Parameters

\Horde_Mime_Headers_Element $ob

Header object to add.

Throws

\InvalidArgumentException

removeHeader()

removeHeader(string  $header) 

Removes a message header.

Parameters

string $header

The header name.

setBody()

setBody(string  $body, string  $charset = null, boolean|integer  $wrap = false) 

Sets the message body text.

Parameters

string $body

The message content.

string $charset

The character set of the message.

boolean|integer $wrap

If true, wrap the message at column 76; If an integer wrap the message at that column. Don't use wrapping if sending flowed messages.

setHtmlBody()

setHtmlBody(string  $body, string  $charset = null, boolean  $alternative = true) 

Sets the HTML message body text.

Parameters

string $body

The message content.

string $charset

The character set of the message.

boolean $alternative

If true, a multipart/alternative message is created and the text/plain part is generated automatically. If false, a text/html message is generated.

addPart()

addPart(string  $mime_type, string  $content, string  $charset = 'us-ascii', string  $disposition = null) : integer

Adds a message part.

Parameters

string $mime_type

The content type of the part.

string $content

The content of the part.

string $charset

The character set of the part.

string $disposition

The content disposition of the part.

Returns

integer —

The part number.

addMimePart()

addMimePart(\Horde_Mime_Part  $part) : integer

Adds a MIME message part.

Parameters

\Horde_Mime_Part $part

A Horde_Mime_Part object.

Returns

integer —

The part number.

setBasePart()

setBasePart(\Horde_Mime_Part  $part) 

Sets the base MIME part.

If the base part is set, any text bodies will be ignored when building the message.

Parameters

\Horde_Mime_Part $part

A Horde_Mime_Part object.

addAttachment()

addAttachment(string  $file, string  $name = null, string  $type = null, string  $charset = 'us-ascii') : integer

Adds an attachment.

Parameters

string $file

The path to the file.

string $name

The file name to use for the attachment.

string $type

The content type of the file.

string $charset

The character set of the part (only relevant for text parts.

Returns

integer —

The part number.

removePart()

removePart(integer  $part) 

Removes a message part.

Parameters

integer $part

The part number.

clearParts()

clearParts() 

Removes all (additional) message parts but leaves the body parts untouched.

addRecipients()

addRecipients(  $recipients) 

Adds message recipients.

Recipients specified by To:, Cc:, or Bcc: headers are added automatically.

Parameters

$recipients

Throws

\Horde_Mime_Exception

removeRecipients()

removeRecipients(  $recipients) 

Removes message recipients.

Parameters

$recipients

Throws

\Horde_Mime_Exception

clearRecipients()

clearRecipients() 

Removes all message recipients.

send()

send(\Mail  $mailer, boolean  $resend = false, boolean  $flowed = true) 

Sends this message.

Parameters

\Mail $mailer

A Mail object.

boolean $resend

If true, the message id and date are re-used; If false, they will be updated.

boolean $flowed

Send message in flowed text format.

Throws

\Horde_Mime_Exception

getRaw()

getRaw(boolean  $stream = true) : \stream|string

Get the raw email data sent by this object.

Parameters

boolean $stream

If true, return a stream resource, otherwise a string is returned.

Returns

\stream|string —

The raw email data.

getBasePart()

getBasePart() : \Horde_Mime_Part

Return the base MIME part.

Returns

\Horde_Mime_Part