PHP based wrapper class to connect to an IMAP server
| package |
Framework |
|---|---|
| subpackage |
Storage |
_connect(string $host) : boolean
stringServer hostname or IP
booleanTrue on success, False on failure
_listMailboxes(string $ref, string $mailbox, boolean $subscribed = false, array $return_opts = array(), array $select_opts = array()) : array|boolean
stringReference name
stringMailbox name
booleanEnables returning subscribed mailboxes only
arrayList of RETURN options (RFC5819: LIST-STATUS, RFC5258: LIST-EXTENDED) Possible: MESSAGES, RECENT, UIDNEXT, UIDVALIDITY, UNSEEN, MYRIGHTS, SUBSCRIBED, CHILDREN
arrayList of selection options (RFC5258: LIST-EXTENDED) Possible: SUBSCRIBED, RECURSIVEMATCH, REMOTE, SPECIAL-USE (RFC6154)
array|booleanList of mailboxes or hash of options if STATUS/MYROGHTS response is requested, False on error.
_xor( $string, $string2)
append(string $mailbox, string|array &$message, array $flags = array(), string $date = null, boolean $binary = false) : string|boolean
stringMailbox name
string|arrayThe message source string or array (of strings and file pointers)
arrayMessage flags
stringMessage internal date
booleanEnable BINARY append (RFC3516)
string|booleanOn success APPENDUID response (if available) or True, False on failure
appendFromFile(string $mailbox, string $path, string $headers = null, array $flags = array(), string $date = null, boolean $binary = false) : string|boolean
stringMailbox name
stringPath to the file with message body
stringMessage headers
arrayMessage flags
stringMessage internal date
booleanEnable BINARY append (RFC3516)
string|booleanOn success APPENDUID response (if available) or True, False on failure
authenticate(string $user, string $pass, string $type = 'PLAIN') : resource
stringUsername
stringPassword
stringAuthentication type (PLAIN/CRAM-MD5/DIGEST-MD5)
resourceConnection resourse on success, error code on error
clear_mailbox_cache()
clear_status_cache( $mailbox)
clearCapability()
clearFolder(string $mailbox) : boolean
stringMailbox name
booleanTrue on success, False on error
close() : boolean
| since | 0.5 |
|---|---|
booleanTrue on success, False on error
closeConnection()
closeSocket()
compressMessageSet(array $messages, boolean $force = false) : string
arrayMessage identifiers
booleanForces compression of any size
stringCompressed sequence-set
connect(string $host, string $user, string $password, array $options = array()) : boolean
stringServer hostname or IP
stringUser name
stringPassword
arrayConnection and class options
booleanTrue on success, False on failure
connected() : boolean
booleanTrue if connection is active and user is logged in, False otherwise.
copy(string|array $messages, string $from, string $to) : boolean
string|arrayMessage UID(s)
stringMailbox name
stringDestination mailbox name
booleanTrue on success, False on failure
countMessages(string $mailbox) : integer
stringMailbox name
integerNumber of messages, False on error
countRecent(string $mailbox) : integer
stringMailbox name
integerNumber of messages, False on error
countUnseen(string $mailbox) : integer
stringMailbox name
integerNumber of messages, False on error
createFolder(string $mailbox, array $types = null) : boolean
stringMailbox name
arrayOptional folder types (RFC 6154)
booleanTrue on success, False on error
debug(string $message)
| since | 0.5-stable |
|---|---|
stringDebug mesage text.
deleteACL(string $mailbox, string $user) : boolean
| since | 0.5-beta |
|---|
stringMailbox name
stringUser name
booleanTrue on success, False on failure
deleteAnnotation(string $mailbox, array $data) : boolean
| since | 0.5-beta |
|---|
stringMailbox name
arrayData array where each item is an array with two elements: entry name and attribute name
booleanTrue on success, False on failure
deleteFolder(string $mailbox) : boolean
stringMailbox name
booleanTrue on success, False on error
deleteMetadata(string $mailbox, array $entries) : boolean
| since | 0.5-beta |
|---|
stringMailbox name
arrayEntry names array
booleanTrue on success, False on failure
enable(mixed $extension) : array|boolean
| since | 0.6 |
|---|
mixedExtension name to enable (or array of names)
array|booleanList of enabled extensions, False on error
eof() : boolean
booleanTrue if connection is closed
escape(string $string, boolean $force_quotes = false) : string
| todo |
lists |
|---|
stringIMAP string
booleanForces string quoting (for atoms)
stringString atom, quoted-string or string literal
execute(string $command, array $arguments = array(), integer $options) : mixed
| since | 0.5-beta |
|---|
stringIMAP command
arrayCommand arguments
integerExecution options
mixedResponse code or list of response code and data
expunge(string $mailbox, string|array $messages = null) : boolean
stringMailbox name
string|arrayMessage UIDs to expunge
booleanTrue on success, False on error
fetch(string $mailbox, mixed $message_set, boolean $is_uid = false, array $query_items = array(), string $mod_seq = null, boolean $vanished = false) : array
| since | 0.6 |
|---|
stringMailbox name
mixedMessage(s) sequence identifier(s) or UID(s)
booleanTrue if $message_set contains UIDs
arrayFETCH command data items
stringModification sequence for CHANGEDSINCE (RFC4551) query
booleanEnables VANISHED parameter (RFC5162) for CHANGEDSINCE query
arrayList of rcube_message_header elements, False on error
fetchHeader(string $mailbox, integer $id, boolean $is_uid = false, boolean $bodystr = false, array $add_headers = array()) : boolean|\rcube_message_header
stringMailbox name
integerMessage sequence identifier or UID
booleanTrue if $id is an UID
booleanEnable to add BODYSTRUCTURE data to the result
arrayList of additional headers
boolean|\rcube_message_headerMessage data, False on error
fetchHeaderIndex(string $mailbox, string|array $message_set, string $index_field = '', boolean $skip_deleted = true, boolean $uidfetch = false, boolean $return_uid = false) : array|boolean
stringMailbox name
string|arraySearching criteria (list of messages to return)
stringField to sort by (ARRIVAL, CC, DATE, FROM, SIZE, SUBJECT, TO)
booleanMakes that DELETED messages will be skipped
booleanEnables UID FETCH usage
booleanEnables returning UIDs instead of IDs
array|booleanList of header values or False on failure
fetchHeaders(string $mailbox, mixed $message_set, boolean $is_uid = false, boolean $bodystr = false, array $add_headers = array()) : boolean|array
stringMailbox name
mixedMessage(s) sequence identifier(s) or UID(s)
booleanTrue if $message_set contains UIDs
booleanEnable to add BODYSTRUCTURE data to the result
arrayList of additional headers
boolean|arrayList of rcube_message_header elements, False on error
fetchMIMEHeaders(string $mailbox, integer $uid, array $parts, boolean $mime = true) : array|boolean
stringMailbox name
integerMessage UID
arrayMessage part identifiers
booleanUse MIME instad of HEADER
array|booleanArray containing headers string for each specified body False on failure.
fetchPartHeader( $mailbox, $id, $is_uid = false, $part = null)
flag(string $mailbox, string|array $messages, string $flag) : boolean
stringMailbox name
string|arrayMessage UID(s)
stringFlag name
booleanTrue on success, False on failure
flagsToStr(array $flags) : string
arrayFlags (see self::flags)
stringSpace-separated list of flags
getACL(string $mailbox) : array
| since | 0.5-beta |
|---|
stringMailbox name
arrayUser-rights array on success, NULL on error
getAnnotation(string $mailbox, array $entries, array $attribs) : array
| since | 0.5-beta |
|---|
stringMailbox name
arrayEntries names
arrayAttribs names
arrayAnnotations result on success, NULL on error
getCapability(string $name) : mixed
stringCapability name
mixedCapability values array for key=value pairs, true/false for others
getHierarchyDelimiter() : string
stringThe delimiter
getMetadata(string $mailbox, array $entries, array $options = array()) : array
| since | 0.5-beta |
|---|
stringMailbox name
arrayEntries
arrayCommand options (with MAXSIZE and DEPTH keys)
arrayGETMETADATA result on success, NULL on error
getNamespace() : array
arrayNamespace data hash (personal, other, shared)
getQuota(string $mailbox = null) : array
stringMailbox name
arrayQuota information
getStructure(string $mailbox, integer $id, boolean $is_uid = false) : \array/bool
| since | 0.6 |
|---|
stringFolder name
integerMessage sequence number or UID
booleanTrue if $id is an UID
\array/boolBody structure array or False on error.
getStructurePartArray( $a, $part)
getStructurePartData(array $structure, string $part) : array
arrayMessage structure (getStructure() result)
stringMessage part identifier
arrayPart data as hash array (type, encoding, charset, size)
handlePartBody( $mailbox, $id, $is_uid = false, $part = '', $encoding = null, $print = null, $file = null, $formatted = false, $max_bytes)
hasCapability( $name)
id(array $items = array()) : array
| since | 0.6 |
|---|
arrayClient identification information key/value hash
arrayServer identification information key/value hash
ID2UID(string $mailbox, $id) : integer
stringMailbox name
integerMessage unique identifier
index(string $mailbox, string|array $message_set, string $index_field = '', boolean $skip_deleted = true, boolean $uidfetch = false, boolean $return_uid = false) : \rcube_result_index
stringMailbox name
string|arraySearching criteria (list of messages to return)
stringField to sort by (ARRIVAL, CC, DATE, FROM, SIZE, SUBJECT, TO)
booleanMakes that DELETED messages will be skipped
booleanEnables UID FETCH usage
booleanEnables returning UIDs instead of IDs
\rcube_result_indexResponse data
listMailboxes(string $ref, string $mailbox, array $return_opts = array(), array $select_opts = array()) : array|boolean
stringReference name
stringMailbox name
array(see self::_listMailboxes)
array(see self::_listMailboxes)
array|booleanList of mailboxes or hash of options if STATUS/MYROGHTS response is requested, False on error.
listRights(string $mailbox, string $user) : array
| since | 0.5-beta |
|---|
stringMailbox name
stringUser name
arrayList of user rights
listSubscribed(string $ref, string $mailbox, array $return_opts = array()) : array|boolean
stringReference name
stringMailbox name
array(see self::_listMailboxes)
array|booleanList of mailboxes or hash of options if STATUS/MYROGHTS response is requested, False on error.
login(string $user, $password) : resource
stringUsername
resourceConnection resourse on success, error code on error
modFlag(string $mailbox, string|array $messages, string $flag, string $mod = '+') : boolean
stringMailbox name
string|arrayMessage UID(s)
stringFlag name
stringModifier [+|-]. Default: "+".
booleanTrue on success, False on failure
move(string|array $messages, string $from, string $to) : boolean
string|arrayMessage UID(s)
stringMailbox name
stringDestination mailbox name
booleanTrue on success, False on failure
multLine(string $line, boolean $escape = false) : string
stringResponse text
booleanEnables escaping
stringLine of text response
myRights(string $mailbox) : array
| since | 0.5-beta |
|---|
stringMailbox name
arrayMYRIGHTS response on success, NULL on error
nextTag() : string
| since | 0.5-beta |
|---|---|
stringCommand identifier
parseCapability( $str, $trusted = false)
parseResult(string $string, string $err_prefix = '') : integer
stringResponse text
stringError message prefix
integerResponse status
putLine(string $string, boolean $endln = true, boolean $anonymized = false)
stringCommand string
booleanTrue if CRLF need to be added at the end of command
booleanDon't write the given data to log but a placeholder
putLineC(string $string, boolean $endln = true, boolean $anonymized = false) : integer|boolean
stringCommand string
booleanTrue if CRLF need to be added at the end of command
booleanDon't write the given data to log but a placeholder
integer|booleanNumber of bytes sent, False on error
r_implode( $element)
readBytes(integer $bytes) : string
integerNumber of bytes to get
stringResponse text
readLine(integer $size = 1024) : string
integerBuffer size
stringLine of text response
readReply(array &$untagged = null) : string
arrayWill be filled with untagged response lines
stringResponse text
renameFolder( $from, $to) : boolean
booleanTrue on success, False on error
search(string $mailbox, string $criteria, boolean $return_uid = false, array $items = array()) : \rcube_result_index
stringMailbox name
stringSearching criteria
booleanEnable UID in result instead of sequence ID
arrayReturn items (MIN, MAX, COUNT, ALL)
\rcube_result_indexResult data
select(string $mailbox, array $qresync_data = null) : boolean
stringMailbox name
arrayQRESYNC data (RFC5162)
booleanTrue on success, false on error
set_prefs( $prefs)
setACL(string $mailbox, string $user, mixed $acl) : boolean
| since | 0.5-beta |
|---|
stringMailbox name
stringUser name
mixedACL string or array
booleanTrue on success, False on failure
setAnnotation(string $mailbox, array $data) : boolean
| since | 0.5-beta |
|---|
stringMailbox name
arrayData array where each item is an array with three elements: entry name, attribute name, value
booleanTrue on success, False on failure
setDebug(boolean $debug, callback $handler = null)
| since | 0.5-stable |
|---|---|
booleanNew value for the debugging flag.
callbackLogging handler function
setError( $code, $msg = '')
setMetadata(string $mailbox, array $entries) : boolean
| since | 0.5-beta |
|---|
stringMailbox name
arrayEntry-value array (use NULL value as NIL)
booleanTrue on success, False on failure
sort(string $mailbox, string $field = 'ARRIVAL', string $criteria = '', boolean $return_uid = false, string $encoding = 'US-ASCII') : \rcube_result_index
stringMailbox name
stringField to sort by (ARRIVAL, CC, DATE, FROM, SIZE, SUBJECT, TO)
stringSearching criteria
booleanEnables UID SORT usage
stringCharacter set
\rcube_result_indexResponse data
sortHeaders(array $messages, string $field, string $flag) : array
arrayArray of rcube_message_header objects
stringName of the property to sort by
stringSorting order (ASC|DESC)
arraySorted input array
startsWith(string $string, string $match, boolean $error = false, boolean $nonempty = false) : boolean
Checks if command response line starts with specified prefix (or * BYE/BAD)
stringResponse text
stringPrefix to match with (case-sensitive)
booleanEnables BYE/BAD checking
booleanEnables empty response checking
booleanTrue any check is true or connection is closed.
status(string $mailbox, array $items = array()) : array
| since | 0.5-beta |
|---|
stringMailbox name
arrayAdditional requested item names. By default MESSAGES and UNSEEN are requested. Other defined in RFC3501: UIDNEXT, UIDVALIDITY, RECENT
arrayStatus item-value hash
strToTime(string $date) : integer
stringDate string
integerUnix timestamp
subscribe(string $mailbox) : boolean
stringMailbox name
booleanTrue on success, False on error
thread(string $mailbox, string $algorithm = 'REFERENCES', string $criteria = '', boolean $return_uid = false, string $encoding = 'US-ASCII') : \rcube_result_thread
stringMailbox name
stringThreading algorithm (ORDEREDSUBJECT, REFERENCES, REFS)
stringSearching criteria
booleanEnables UIDs in result instead of sequence numbers
stringCharacter set
\rcube_result_threadThread data
tokenizeResponse( &$str, integer $num) : mixed
| since | 0.5-beta |
|---|
integerNumber of tokens to return
mixedTokens array or string if $num=1
UID2ID(string $mailbox, integer $uid) : integer
stringMailbox name
integerMessage unique identifier (UID)
integerMessage sequence identifier
uncompressMessageSet(string $messages) : array
stringMessage identifiers
arrayList of message identifiers
unflag(string $mailbox, string|array $messages, string $flag) : boolean
stringMailbox name
string|arrayMessage UID(s)
stringFlag name
booleanTrue on success, False on failure
unsubscribe(string $mailbox) : boolean
stringMailbox name
booleanTrue on success, False on error
ERROR_OK
ERROR_NO
ERROR_BAD
ERROR_BYE
ERROR_UNKNOWN
ERROR_COMMAND
ERROR_READONLY
COMMAND_NORESPONSE
COMMAND_CAPABILITY
COMMAND_LASTLINE
COMMAND_ANONYMIZED
DEBUG_LINE_LENGTH
error :
errornum :
result :
resultcode :
selected :
data :
flags :
fp :
host :
cmd_tag :
cmd_num :
resourceid :
prefs :
logged :
capability :
capability_readed :
debug :
debug_handler :