Documentation

Horde_ActiveSync_Imap_Adapter
in package

Horde_ActiveSync_Imap_Adapter contains methods for communicating with Horde's Horde_Imap_Client library.

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

MAX_FETCH  = 2000
Maximum number of of messages to fetch from the IMAP server in one go.
$_defaultNamespace  : string
$_imap  : Horde_ActiveSync_Interface_ImapFactory
$_logger  : Horde_Log_Logger
$_options  : mixed
Additional options
$_procid  : int
Process id used for logging.
__construct()  : mixed
Cont'r
appendMessage()  : int|bool
Append a message to the specified mailbox. Used for saving sent email.
categoriesToFlags()  : mixed
createMailbox()  : mixed
Create a new mailbox on the server, and subscribe to it.
deleteMailbox()  : mixed
Delete a mailbox
deleteMessages()  : array<string|int, mixed>
Permanently delete a mail message.
emptyMailbox()  : mixed
Completely empty specified mailbox.
getAttachment()  : Horde_Mime_Part
Return the content of a specific MIME part of the specified message.
getImapMessage()  : array<string|int, mixed>
Return a complete Horde_ActiveSync_Imap_Message object for the requested uid.
getMailboxes()  : array<string|int, mixed>
Return an array of available mailboxes. Uses's the mail/mailboxList API method for obtaining the list.
getMessageChanges()  : Horde_ActiveSync_Folder_Imap
Return message changes from the specified mailbox.
getMessages()  : array<string|int, mixed>
Return AS mail messages, from the given IMAP UIDs.
getSpecialMailboxes()  : array<string|int, mixed>
Return the list of special mailboxes.
getUidFromMid()  : int
Return a message UIDs from the given Message-ID.
getUidFromMidInFolders()  : array<string|int, mixed>
Attempt to find a Message-ID in a list of mail folders.
moveMessage()  : array<string|int, mixed>
Move a mail message
ping()  : bool
Ping a mailbox. This detects only if any new messages have arrived in the specified mailbox.
queryMailbox()  : array<string|int, mixed>
Perform a search from a search mailbox request.
renameMailbox()  : string
Rename a mailbox
setImapFlag()  : mixed
Set a IMAP message flag.
setLogger()  : mixed
Set this instance's logger.
setMessageFlag()  : mixed
Set a POOMMAIL_FLAG on a mail message. This method differs from setReadFlag() in that it is passed a Flag object, which contains other data beside the seen status. Used for setting flagged for followup and potentially creating tasks based on the email.
setOptions()  : mixed
Set additional options for this request.
setReadFlag()  : mixed
Set the message's read status.
_buildMailMessage()  : Horde_ActiveSync_Message_Mail
Builds a proper AS mail message object.
_buildSubQuery()  : Horde_Imap_Client_Search_Query
Helper to build a subquery
_defaultNamespace()  : array<string|int, mixed>
Return the default namespace.
_doQuery()  : array<string|int, mixed>
Perform an IMAP search based on a SEARCH request.
_getImapOb()  : Horde_Imap_Client_Base
Helper to obtain a valid IMAP client. Can't inject it since the user is not yet authenticated at the time of object creation.
_getMailMessages()  : Horde_Imap_Fetch_Results
_getMsgFlags()  : mixed
_getNamespace()  : mixed
_getNamespacelist()  : array<string|int, mixed>
Return the list of configured namespaces on the IMAP server.
_mailboxExists()  : bool
Check existence of a mailbox.
_prependNamespace()  : string
Prefix the default namespace to mailbox name if needed.

Constants

MAX_FETCH

Maximum number of of messages to fetch from the IMAP server in one go.

public mixed MAX_FETCH = 2000

Properties

$_defaultNamespace

protected string $_defaultNamespace

$_logger

protected Horde_Log_Logger $_logger

$_options

Additional options

protected mixed $_options = array()
Tags
since
2.40.0

$_procid

Process id used for logging.

protected int $_procid

Methods

__construct()

Cont'r

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

Parameters:

  • factory: (Horde_ActiveSync_Interface_ImapFactory) Factory object DEFAULT: none - REQUIRED
Return values
mixed

appendMessage()

Append a message to the specified mailbox. Used for saving sent email.

public appendMessage(string $folderid, string|stream $msg[, array<string|int, mixed> $flags = array() ]) : int|bool
Parameters
$folderid : string

The mailbox

$msg : string|stream

The message

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

Any flags to set on the newly appended message.

Tags
throws
new

Horde_ActiveSync_Exception, Horde_ActiveSync_Exception_FolderGone

Return values
int|bool

The imap uid of the appended message or false on failure. @since 2.37.0

categoriesToFlags()

public categoriesToFlags(mixed $mailbox, mixed $categories, mixed $uid) : mixed
Parameters
$mailbox : mixed
$categories : mixed
$uid : mixed
Return values
mixed

createMailbox()

Create a new mailbox on the server, and subscribe to it.

public createMailbox(string $name[, string $parent = null ]) : mixed
Parameters
$name : string

The new mailbox name.

$parent : string = null

The parent mailbox, if any.

@return string The new serverid for the mailbox. This is the UTF-8 name of the mailbox. @since 2.9.0 @throws Horde_ActiveSync_Exception, Horde_ActiveSync_Exception_FolderExists

Return values
mixed

deleteMailbox()

Delete a mailbox

public deleteMailbox(string $name) : mixed
Parameters
$name : string

The mailbox name to delete.

Tags
throws

Horde_ActiveSync_Exception, Horde_ActiveSync_Exception_FolderGone

Return values
mixed

deleteMessages()

Permanently delete a mail message.

public deleteMessages(array<string|int, mixed> $uids, string $folderid) : array<string|int, mixed>
Parameters
$uids : array<string|int, mixed>

The message UIDs

$folderid : string

The folder id.

Tags
throws
Horde_ActiveSync_Exception
Return values
array<string|int, mixed>

An array of uids that were successfully deleted.

emptyMailbox()

Completely empty specified mailbox.

public emptyMailbox(string $mbox) : mixed
Parameters
$mbox : string

The mailbox to empty.

Tags
throws
Horde_ActiveSync_Exception
since
2.18.0
Return values
mixed

getAttachment()

Return the content of a specific MIME part of the specified message.

public getAttachment(string $mailbox, string $uid, string $part) : Horde_Mime_Part
Parameters
$mailbox : string

The mailbox name.

$uid : string

The message UID.

$part : string

The MIME part identifier.

Tags
throws
Horde_ActiveSync_Exception
Return values
Horde_Mime_Part

The attachment data

getImapMessage()

Return a complete Horde_ActiveSync_Imap_Message object for the requested uid.

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

The mailbox name.

$uid : array<string|int, mixed>|int

The message uid.

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

Additional options:

  • headers: (boolean) Also fetch the message headers if this is true. DEFAULT: false (Do not fetch headers).
Tags
todo

This should be renamed to getImapMessages since we can now accept an array of $uids.

Return values
array<string|int, mixed>

An array of Horde_ActiveSync_Imap_Message objects.

getMailboxes()

Return an array of available mailboxes. Uses's the mail/mailboxList API method for obtaining the list.

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

getMessageChanges()

Return message changes from the specified mailbox.

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

The folder object.

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

Additional options:

  • sincedate: (integer) Timestamp of earliest message to retrieve. DEFAULT: 0 (Don't filter).
  • protocolversion: (float) EAS protocol version to support. DEFAULT: none REQUIRED
  • softdelete: (boolean) If true, calculate SOFTDELETE data. @since 2.8.0
  • refreshfilter: (boolean) If true, force refresh the query to reflect changes in FILTERTYPE (using the sincedate) @since 2.28.0
Tags
throws

Horde_ActiveSync_Exception_FolderGone, Horde_ActiveSync_Exception, Horde_ActiveSync_Exception_StaleState

Return values
Horde_ActiveSync_Folder_Imap

The folder object, containing any change instructions for the device.

getMessages()

Return AS mail messages, from the given IMAP UIDs.

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

The mailbox folder.

$messages : array<string|int, mixed>

List of IMAP message UIDs

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

Additional Options:

  • truncation: (integer) The truncation constant, if sent from device. DEFAULT: false (No truncation).
  • bodyprefs: (array) The bodypref settings, if sent from device. DEFAULT: none (No body prefs sent, or enforced).
  • bodypartprefs: (array) The bodypartprefs settings, if present.
  • 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 version to support. DEFAULT: 2.5
Return values
array<string|int, mixed>

An array of Horde_ActiveSync_Message_Mail objects.

getSpecialMailboxes()

Return the list of special mailboxes.

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

getUidFromMid()

Return a message UIDs from the given Message-ID.

public getUidFromMid(string $mid, Horde_ActiveSync_Folder_Imap $folder) : int
Parameters
$mid : string

The Message-ID

$folder : Horde_ActiveSync_Folder_Imap

The folder object to search.

Tags
throws
Horde_Exception_NotFound
Return values
int

The UID

getUidFromMidInFolders()

Attempt to find a Message-ID in a list of mail folders.

public getUidFromMidInFolders(mixed $id, array<string|int, mixed> $folders) : array<string|int, mixed>
Parameters
$id : mixed
$folders : array<string|int, mixed>
Tags
throws

Horde_Exception_NotFound, Horde_ActiveSync_Exception

deprecated

This is unused and should be removed.

Return values
array<string|int, mixed>

An array with the 0 element being the mbox

moveMessage()

Move a mail message

public moveMessage(string $folderid, array<string|int, mixed> $ids, string $newfolderid) : array<string|int, mixed>
Parameters
$folderid : string

The existing folderid.

$ids : array<string|int, mixed>

The message UIDs of the messages to move.

$newfolderid : string

The folder id to move $id to.

Tags
throws
Horde_ActiveSync_Exception
Return values
array<string|int, mixed>

An hash of oldUID => newUID.

ping()

Ping a mailbox. This detects only if any new messages have arrived in the specified mailbox.

public ping(Horde_ActiveSync_Folder_Imap $folder) : bool
Parameters
$folder : Horde_ActiveSync_Folder_Imap

The folder object.

Tags
throws

Horde_ActiveSync_Exception, Horde_ActiveSync_Exception_FolderGone

Return values
bool

True if changes were detected, otherwise false.

queryMailbox()

Perform a search from a search mailbox request.

public queryMailbox(array<string|int, mixed> $query) : array<string|int, mixed>
Parameters
$query : array<string|int, mixed>

The query array.

Return values
array<string|int, mixed>

An array of 'uniqueid', 'searchfolderid' hashes.

renameMailbox()

Rename a mailbox

public renameMailbox(string $old, string $new[, string $parent = null ]) : string
Parameters
$old : string

The old mailbox name.

$new : string

The new mailbox name.

$parent : string = null

The parent mailbox, if any.

Tags
throws
Horde_ActiveSync_Exception
Return values
string

The new serverid for the mailbox. @since 2.9.0

setImapFlag()

Set a IMAP message flag.

public setImapFlag(string $mailbox, int $uid, string $flag) : mixed
Parameters
$mailbox : string

The mailbox name.

$uid : int

The message UID.

$flag : string

The flag to set. A Horde_ActiveSync:: constant.

Tags
throws
Horde_ActiveSync_Exception
Return values
mixed

setLogger()

Set this instance's logger.

public setLogger(Horde_Log_Logger $logger) : mixed
Parameters
$logger : Horde_Log_Logger

The logger.

Return values
mixed

setMessageFlag()

Set a POOMMAIL_FLAG on a mail message. This method differs from setReadFlag() in that it is passed a Flag object, which contains other data beside the seen status. Used for setting flagged for followup and potentially creating tasks based on the email.

public setMessageFlag(string $mailbox, int $uid, Horde_ActiveSync_Message_Flag $flag) : mixed
Parameters
$mailbox : string

The mailbox name.

$uid : int

The message uid.

$flag : Horde_ActiveSync_Message_Flag

The flag

Tags
throws
Horde_ActiveSync_Exception
Return values
mixed

setOptions()

Set additional options for this request.

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

[description]

Tags
since
2.40.0
Return values
mixed

setReadFlag()

Set the message's read status.

public setReadFlag(string $mailbox, string $uid, int $flag) : mixed
Parameters
$mailbox : string

The mailbox name.

$uid : string

The message uid.

$flag : int

Horde_ActiveSync_Message_Mail::FLAG_* constant

Tags
throws
Horde_ActiveSync_Exception
Return values
mixed

_buildMailMessage()

Builds a proper AS mail message object.

protected _buildMailMessage(Horde_Imap_Client_Mailbox $mbox, Horde_Imap_Client_Data_Fetch $data[, array<string|int, mixed> $options = array() ]) : Horde_ActiveSync_Message_Mail
Parameters
$mbox : Horde_Imap_Client_Mailbox

The IMAP mailbox.

$data : Horde_Imap_Client_Data_Fetch

The fetch results.

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

Additional Options:

  • truncation: (integer) Truncate the message body to this length. DEFAULT: No truncation.
  • bodyprefs: (array) Bodyprefs, if sent from device. DEFAULT: none (No body prefs sent or enforced).
  • bodypartprefs: (array) Bodypartprefs, if sent from device. DEFAULT: none (No body part prefs sent or enforced).
  • 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 version to support. DEFAULT: 2.5
Return values
Horde_ActiveSync_Message_Mail

The message object suitable for streaming to the device.

_buildSubQuery()

Helper to build a subquery

protected _buildSubQuery(array<string|int, mixed> $query) : Horde_Imap_Client_Search_Query
Parameters
$query : array<string|int, mixed>

A subquery array.

Return values
Horde_Imap_Client_Search_Query

The query object.

_defaultNamespace()

Return the default namespace.

protected _defaultNamespace() : array<string|int, mixed>
Return values
array<string|int, mixed>

The namespace data.

_doQuery()

Perform an IMAP search based on a SEARCH request.

protected _doQuery(array<string|int, mixed> $query) : array<string|int, mixed>
Parameters
$query : array<string|int, mixed>

The search query.

Tags
throws
Horde_ActiveSync_Exception
Return values
array<string|int, mixed>

The results array containing an array of hashes: 'uniqueid' => [The unique identifier of the result] 'searchfolderid' => [The mailbox name that this result comes from]

_getImapOb()

Helper to obtain a valid IMAP client. Can't inject it since the user is not yet authenticated at the time of object creation.

protected _getImapOb() : Horde_Imap_Client_Base
Tags
throws
Horde_ActiveSync_Exception
Return values
Horde_Imap_Client_Base

_getMailMessages()

protected _getMailMessages(Horde_Imap_Client_Mailbox $mbox, array<string|int, mixed> $uids[, array<string|int, mixed> $options = array() ]) : Horde_Imap_Fetch_Results
Parameters
$mbox : Horde_Imap_Client_Mailbox

The mailbox

$uids : array<string|int, mixed>

An array of message uids

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

An options array

  • headers: (boolean) Fetch header text if true. DEFAULT: false (Do not fetch header text).
  • structure: (boolean) Fetch message structure. DEFAULT: true (Fetch message structure).
  • flags: (boolean) Fetch messagge flags. DEFAULT: true (Fetch message flags).
  • envelope: (boolen) Fetch the envelope data. DEFAULT: false (Do not fetch envelope). @since 2.4.0
Tags
throws
Horde_ActiveSync_Exception
Return values
Horde_Imap_Fetch_Results

The results.

_getMsgFlags()

protected _getMsgFlags() : mixed
Return values
mixed

_getNamespace()

protected _getNamespace(mixed $path) : mixed
Parameters
$path : mixed
Return values
mixed

_getNamespacelist()

Return the list of configured namespaces on the IMAP server.

protected _getNamespacelist() : array<string|int, mixed>
Return values
array<string|int, mixed>

_mailboxExists()

Check existence of a mailbox.

protected _mailboxExists(string $mbox) : bool
Parameters
$mbox : string

The mailbox name.

Return values
bool

_prependNamespace()

Prefix the default namespace to mailbox name if needed.

protected _prependNamespace(string $name) : string
Parameters
$name : string

The mailbox name.

Return values
string

The mailbox name with the default namespace added, if needed.

Search results