Documentation

Horde_ActiveSync_Imap_Message
in package

This class provides all functionality related to parsing and working with a single IMAP email message when using Horde_Imap_Client.

Some Mime parsing code taken from Imp_Contents.

Tags
license

http://www.horde.org/licenses/gpl GPLv2

copyright

2012-2020 Horde LLC (http://www.horde.org)

author

Michael J Rubinsky mrubinsk@horde.org

Table of Contents

OPTIONS_DECODE_TNEF  = "decode_tnef"
$basePart  : Horde_ActiveSync_Mime
$envelope  : Horde_Imap_Client_Data_Envelope
$flags  : array<string|int, mixed>
$uid  : int
$_basePart  : Horde_ActiveSync_Mime
Message structure.
$_data  : Horde_Imap_Client_Data_Fetch
Message data.
$_hasAttachments  : bool
Flag to indicate if this message contains attachments.
$_imap  : Horde_Imap_Client_Base
The imap client.
$_lastBodyPartDecode  : bool
Cache if the last body part was encoded or not.
$_mbd  : Horde_ActiveSync_Imap_MessageBodyData
Local cache of MessageBodyData object.
$_options  : array<string|int, mixed>
Additional message options
$_tnefPrepared  : bool
Flag to indicate the mime map was processed for potential TNEF parts.
__construct()  : mixed
Constructor
__destruct()  : mixed
__get()  : mixed
Accessor
contentTypeMap()  : array<string|int, mixed>
Return this message's content map
getAttachments()  : array<string|int, mixed>
Return an array of Horde_ActiveSync_Message_Attachment objects for the current message.
getAttachmentsMimeParts()  : array<string|int, mixed>
Return an array of mime parts for each message attachment.
getBodyPart()  : mixed
Gets the raw text for one section of the message.
getCc()  : string
Return the CC addresses for this message.
getDate()  : Horde_Date
Return the message date.
getFlag()  : bool
Get a message flag
getFlags()  : array<string|int, mixed>
Return all message flags.
getForwardHeaders()  : string
Return nicely formatted text representing the headers to display with in-line forwarded messages.
getFromAddress()  : string
Return the message's From: address.
getFullMsg()  : mixed
Return the full message text.
getHeaders()  : Horde_Mime_Headers
Return this message's base part headers.
getMessageBodyData()  : array<string|int, mixed>
Returns the main text body of the message suitable for sending over EAS response.
getMessageBodyDataObject()  : Horde_ActiveSync_Imap_MessageBodyData
Returns the main text body of the message suitable for sending over EAS response.
getMimePart()  : Horde_Mime_Part
Fetch a part of a MIME message.
getPartName()  : string
Return the descriptive part label, making sure it is not empty.
getReplyTo()  : string
Return the ReplyTo Address
getStructure()  : Horde_Mime_Part
Return the message's base Mime part.
getSubject()  : string
Return the message subject.
getToAddresses()  : array<string|int, mixed>
Return the To addresses from this message.
hasAttachments()  : bool
Return the hasAttachments flag
hasiCalendar()  : mixed
Return the MIME part of the iCalendar attachment, if available.
isAttachment()  : bool
Determines if a MIME type is an attachment.
isEncrypted()  : bool
Return the S/MIME encryption status of this message (RFC2633)
isSigned()  : bool
Return the S/MIME signature status of this message (RFC2633)
_buildEasAttachmentFromMime()  : Horde_ActiveSync_Message_AirSyncBaseAttachment
Build an appropriate attachment object from the given mime part.
_decodeTnefData()  : Horde_Mime_Part|bool
Convert a TNEF attachment into a multipart/mixed part.
_prepareTnef()  : mixed
Check the mime structure for any TNEF data, and if neccessary attempt to decode data and inject back into the base mime part.

Constants

OPTIONS_DECODE_TNEF

public mixed OPTIONS_DECODE_TNEF = "decode_tnef"

Properties

$envelope read-only

public Horde_Imap_Client_Data_Envelope $envelope

The message envelope.

$flags read-only

public array<string|int, mixed> $flags

The message flags.

$uid read-only

public int $uid

The message uid.

$_data

Message data.

protected Horde_Imap_Client_Data_Fetch $_data

$_hasAttachments

Flag to indicate if this message contains attachments.

protected bool $_hasAttachments

$_imap

The imap client.

protected Horde_Imap_Client_Base $_imap

$_lastBodyPartDecode

Cache if the last body part was encoded or not.

protected bool $_lastBodyPartDecode

$_options

Additional message options

protected array<string|int, mixed> $_options

@since 2.40.0

$_tnefPrepared

Flag to indicate the mime map was processed for potential TNEF parts.

protected bool $_tnefPrepared = \false

Methods

__construct()

Constructor

public __construct(Horde_Imap_Client_Base $imap, Horde_Imap_Client_Mailbox $mbox, Horde_Imap_Client_Data_Fetch $data[, array<string|int, mixed> $options = array() ]) : mixed
Parameters
$imap : Horde_Imap_Client_Base

The imap client object.

$mbox : Horde_Imap_Client_Mailbox

The mailbox object.

$data : Horde_Imap_Client_Data_Fetch

The data returned from a FETCH must contain at least uid, structure and flags.

$options : array<string|int, mixed> = array()

Additional Options @Since 2.40.0 ATTACHEMENT_OPTIONS_DECODE_TNEF - if true will attempt to decode TNEF MIME Parts. If false, will return TNEF data as-is. DEFAULT: True.

Return values
mixed

__destruct()

public __destruct() : mixed
Return values
mixed

__get()

Accessor

public & __get(string $property) : mixed
Parameters
$property : string

The property.

Return values
mixed

contentTypeMap()

Return this message's content map

public contentTypeMap() : array<string|int, mixed>
Return values
array<string|int, mixed>

The content map, with mime ids as keys and content type as values.

getAttachments()

Return an array of Horde_ActiveSync_Message_Attachment objects for the current message.

public getAttachments(float $version) : array<string|int, mixed>
Parameters
$version : float

The EAS protocol version this is for.

Return values
array<string|int, mixed>

An array of Horde_ActiveSync_Message_Attachment objects.

getAttachmentsMimeParts()

Return an array of mime parts for each message attachment.

public getAttachmentsMimeParts() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of Horde_Mime_Part objects.

getBodyPart()

Gets the raw text for one section of the message.

public getBodyPart(int $id, array<string|int, mixed> $options) : mixed
Parameters
$id : int

The ID of the MIME part.

$options : array<string|int, mixed>

Additional options:

  • decode: (boolean) Attempt to decode the bodypart on the remote server. If successful, sets self::$_lastBodyPartDecode to the content-type of the decoded data. DEFAULT: No
  • length: (integer) If set, only download this many bytes of the bodypart from the server. DEFAULT: All data is retrieved.
  • mimeheaders: (boolean) Include the MIME headers also? DEFAULT: No
  • stream: (boolean) If true, return a stream. DEFAULT: No
Tags
throws
Horde_ActiveSync_Exception

when a bodypart cannot be found.

todo

Simplify by removing 'mimeheaders' parameter (not used).

Return values
mixed

The text of the part or a stream resource if 'stream' is true.

getCc()

Return the CC addresses for this message.

public getCc() : string
Tags
throws
Horde_ActiveSync_Exception

@since 2.27.0

Return values
string

The Cc address string.

getDate()

Return the message date.

public getDate() : Horde_Date
Return values
Horde_Date

The messages's envelope date.

getFlag()

Get a message flag

public getFlag(string $flag) : bool
Parameters
$flag : string

The flag to search for.

Return values
bool

getFlags()

Return all message flags.

public getFlags() : array<string|int, mixed>
Tags
since
2.17.0
Return values
array<string|int, mixed>

An array of message flags.

getForwardHeaders()

Return nicely formatted text representing the headers to display with in-line forwarded messages.

public getForwardHeaders() : string
Return values
string

getFromAddress()

Return the message's From: address.

public getFromAddress() : string
Tags
throws
Horde_ActiveSync_Exception

@since 2.27.0

Return values
string

The From address of this message.

getFullMsg()

Return the full message text.

public getFullMsg([bool $stream = false ]) : mixed
Parameters
$stream : bool = false

Return data as a stream?

Tags
throws
Horde_ActiveSync_Exception
Return values
mixed

A string or stream resource.

getHeaders()

Return this message's base part headers.

public getHeaders() : Horde_Mime_Headers
Return values
Horde_Mime_Headers

The message headers.

getMessageBodyData()

Returns the main text body of the message suitable for sending over EAS response.

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

An options array containgin:

  • bodyprefs: (array) Bodypref settings DEFAULT: none (No bodyprefs used).
  • mimesupport: (integer) Indicates if MIME is supported or not. Possible values: 0 - Not supported 1 - Only S/MIME or 2 - All MIME. DEFAULT: 0 (No MIME support)
  • protocolversion: (float) The EAS protocol we are supporting. DEFAULT 2.5
Tags
throws

Horde_ActiveSync_Exception, Horde_Exception_NotFound

deprecated
  • no longer used and will be removed in Horde 6.
Return values
array<string|int, mixed>

An array of one or both of 'plain' and 'html' content.

getMessageBodyDataObject()

Returns the main text body of the message suitable for sending over EAS response.

public getMessageBodyDataObject([array<string|int, mixed> $options = array() ]) : Horde_ActiveSync_Imap_MessageBodyData
Parameters
$options : array<string|int, mixed> = array()

An options array containgin:

  • bodyprefs: (array) Bodypref settings DEFAULT: none (No bodyprefs used).
  • mimesupport: (integer) Indicates if MIME is supported or not. Possible values: 0 - Not supported 1 - Only S/MIME or 2 - All MIME. DEFAULT: 0 (No MIME support)
  • protocolversion: (float) The EAS protocol we are supporting. DEFAULT 2.5
Tags
throws

Horde_ActiveSync_Exception, Horde_Exception_NotFound

Return values
Horde_ActiveSync_Imap_MessageBodyData

The result.

getMimePart()

Fetch a part of a MIME message.

public getMimePart(int $id[, array<string|int, mixed> $options = array() ]) : Horde_Mime_Part
Parameters
$id : int

The MIME index of the part requested.

$options : array<string|int, mixed> = array()

Additional options:

  • length: (integer) If set, only download this many bytes of the bodypart from the server. DEFAULT: All data is retrieved.
  • nocontents: (boolean) If true, don't add the contents to the part DEFAULT: Contents are added to the part
Return values
Horde_Mime_Part

The raw MIME part asked for.

getPartName()

Return the descriptive part label, making sure it is not empty.

public getPartName(Horde_Mime_Part $part[, bool $use_descrip = false ]) : string
Parameters
$part : Horde_Mime_Part

The MIME Part object.

$use_descrip : bool = false

Use description? If false, uses name.

Return values
string

The part label (non-empty).

getStructure()

Return the message's base Mime part.

public getStructure() : Horde_Mime_Part
Return values
Horde_Mime_Part

getSubject()

Return the message subject.

public getSubject() : string
Return values
string

The subject.

getToAddresses()

Return the To addresses from this message.

public getToAddresses() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array containing arrays of 'to' and 'displayto' addresses. @since 2.37.1, ensures the text is UTF8.

hasAttachments()

Return the hasAttachments flag

public hasAttachments() : bool
Return values
bool

hasiCalendar()

Return the MIME part of the iCalendar attachment, if available.

public hasiCalendar() : mixed
Return values
mixed

The mime part, if present, false otherwise.

isAttachment()

Determines if a MIME type is an attachment.

public isAttachment(string $id, string $mime_type) : bool

For our purposes, an attachment is any MIME part that can be downloaded by itself (i.e. all the data needed to view the part is contained within the download data).

Parameters
$id : string

The MIME Id for the part we are checking.

$mime_type : string

The MIME type.

Tags
deprecated

Will be removed in 3.0 (Only used in self::hasAttachments call).

Return values
bool

True if an attachment.

isEncrypted()

Return the S/MIME encryption status of this message (RFC2633)

public isEncrypted([Horde_Mime_Part $message = null ]) : bool
Parameters
$message : Horde_Mime_Part = null

A mime part to check. If omitted, use self::$_message.

Return values
bool

True if message is S/MIME signed or encrypted, false otherwise.

isSigned()

Return the S/MIME signature status of this message (RFC2633)

public isSigned([Horde_Mime_Part $message = null ]) : bool
Parameters
$message : Horde_Mime_Part = null

A mime part to check. If omitted, use self::$_message.

Return values
bool

True if message is S/MIME signed, false otherwise.

_decodeTnefData()

Convert a TNEF attachment into a multipart/mixed part.

protected _decodeTnefData(int|Horde_Mime_part $data) : Horde_Mime_Part|bool
Parameters
$data : int|Horde_Mime_part

Either a mime part id or a Horde_Mime_Part object containing the TNEF attachment.

Return values
Horde_Mime_Part|bool

The multipart/mixed MIME part containing any attachment data we can decode or false on failure.

_prepareTnef()

Check the mime structure for any TNEF data, and if neccessary attempt to decode data and inject back into the base mime part.

protected _prepareTnef() : mixed
Return values
mixed

Search results