Documentation

Horde_Mime_Mail
in package

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.

Tags
author

Jan Schneider jan@horde.org

category

Horde

copyright

2007-2017 Horde LLC

license

http://www.horde.org/licenses/lgpl21 LGPL 2.1

Table of Contents

$_base  : Horde_Mime_Part
The base MIME part.
$_bcc  : string
Bcc recipients.
$_body  : Horde_Mime_Part
The main body part.
$_charset  : string
The charset to use for the message.
$_headers  : Horde_Mime_Headers
The message headers.
$_htmlBody  : Horde_Mime_Part
The main HTML body part.
$_mailer_driver  : string
The Mail driver name.
$_mailer_params  : array<string|int, mixed>
The Mail driver parameters.
$_parts  : array<string|int, mixed>
All MIME parts except the main body part.
$_recipients  : Horde_Mail_Rfc822_List
The message recipients.
__construct()  : mixed
Constructor.
addAttachment()  : int
Adds an attachment.
addHeader()  : mixed
Adds a message header.
addHeaderOb()  : mixed
Add a Horde_Mime_Headers_Element object to the current header list.
addHeaders()  : mixed
Adds several message headers at once.
addMimePart()  : int
Adds a MIME message part.
addPart()  : int
Adds a message part.
addRecipients()  : mixed
Adds message recipients.
clearParts()  : mixed
Removes all (additional) message parts but leaves the body parts untouched.
clearRecipients()  : mixed
Removes all message recipients.
getBasePart()  : Horde_Mime_Part
Return the base MIME part.
getRaw()  : resource|string
Get the raw email data sent by this object.
removeHeader()  : mixed
Removes a message header.
removePart()  : mixed
Removes a message part.
removeRecipients()  : mixed
Removes message recipients.
send()  : mixed
Sends this message.
setBasePart()  : mixed
Sets the base MIME part.
setBody()  : mixed
Sets the message body text.
setHtmlBody()  : mixed
Sets the HTML message body text.

Properties

$_bcc

Bcc recipients.

protected string $_bcc

$_charset

The charset to use for the message.

protected string $_charset = 'UTF-8'

$_parts

All MIME parts except the main body part.

protected array<string|int, mixed> $_parts = array()

$_recipients

The message recipients.

protected Horde_Mail_Rfc822_List $_recipients

Methods

__construct()

Constructor.

public __construct([array<string|int, mixed> $params = array() ]) : mixed
Parameters
$params : array<string|int, mixed> = array()

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.

Tags
throws
Horde_Mime_Exception
Return values
mixed

addAttachment()

Adds an attachment.

public addAttachment(string $file[, string $name = null ][, string $type = null ][, string $charset = 'us-ascii' ]) : int
Parameters
$file : string

The path to the file.

$name : string = null

The file name to use for the attachment.

$type : string = null

The content type of the file.

$charset : string = 'us-ascii'

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

Return values
int

The part number.

addHeader()

Adds a message header.

public addHeader(string $header, string $value[, bool $overwrite = null ]) : mixed
Parameters
$header : string

The header name.

$value : string

The header value.

$overwrite : bool = null

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.

Tags
throws
Horde_Mime_Exception
Return values
mixed

addHeaders()

Adds several message headers at once.

public addHeaders([mixed $headers = array() ]) : mixed
Parameters
$headers : mixed = array()
Tags
throws
Horde_Mime_Exception
Return values
mixed

addMimePart()

Adds a MIME message part.

public addMimePart(Horde_Mime_Part $part) : int
Parameters
$part : Horde_Mime_Part

A Horde_Mime_Part object.

Return values
int

The part number.

addPart()

Adds a message part.

public addPart(string $mime_type, string $content[, string $charset = 'us-ascii' ][, string $disposition = null ]) : int
Parameters
$mime_type : string

The content type of the part.

$content : string

The content of the part.

$charset : string = 'us-ascii'

The character set of the part.

$disposition : string = null

The content disposition of the part.

Return values
int

The part number.

addRecipients()

Adds message recipients.

public addRecipients(mixed $recipients) : mixed

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

Parameters
$recipients : mixed
Tags
throws
Horde_Mime_Exception
Return values
mixed

clearParts()

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

public clearParts() : mixed
Return values
mixed

clearRecipients()

Removes all message recipients.

public clearRecipients() : mixed
Return values
mixed

getRaw()

Get the raw email data sent by this object.

public getRaw([bool $stream = true ]) : resource|string
Parameters
$stream : bool = true

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

Tags
since
2.4.0
Return values
resource|string

The raw email data.

removeHeader()

Removes a message header.

public removeHeader(string $header) : mixed
Parameters
$header : string

The header name.

Return values
mixed

removePart()

Removes a message part.

public removePart(int $part) : mixed
Parameters
$part : int

The part number.

Return values
mixed

removeRecipients()

Removes message recipients.

public removeRecipients(mixed $recipients) : mixed
Parameters
$recipients : mixed
Tags
throws
Horde_Mime_Exception
Return values
mixed

send()

Sends this message.

public send(Horde_Mail_Transport $mailer[, bool $resend = false ][, bool $flowed = true ]) : mixed
Parameters
$mailer : Horde_Mail_Transport

A Horde_Mail_Transport object.

$resend : bool = false

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

$flowed : bool = true

Send message in flowed text format.

Tags
throws
Horde_Mime_Exception
Return values
mixed

setBasePart()

Sets the base MIME part.

public setBasePart(Horde_Mime_Part $part) : mixed

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

Parameters
$part : Horde_Mime_Part

A Horde_Mime_Part object.

Return values
mixed

setBody()

Sets the message body text.

public setBody(string $body[, string $charset = null ][, bool|int $wrap = false ]) : mixed
Parameters
$body : string

The message content.

$charset : string = null

The character set of the message.

$wrap : bool|int = false

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.

Return values
mixed

setHtmlBody()

Sets the HTML message body text.

public setHtmlBody(string $body[, string $charset = null ][, bool $alternative = true ]) : mixed
Parameters
$body : string

The message content.

$charset : string = null

The character set of the message.

$alternative : bool = true

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

Return values
mixed

Search results