PHP based wrapper class to connect to an IMAP server
package |
Framework |
---|---|
subpackage |
Storage |
__construct()
putLine(string $string, bool $endln = true)
string
Command string
bool
True if CRLF need to be added at the end of command
putLineC(string $string, bool $endln = true) : int|bool
string
Command string
bool
True if CRLF need to be added at the end of command
int|bool
Number of bytes sent, False on error
readLine(int $size = 1024) : string
int
Buffer size
string
Line of text response
multLine(string $line, bool $escape = false) : string
string
Response text
bool
Enables escaping
string
Line of text response
readBytes(int $bytes) : string
int
Number of bytes to get
string
Response text
readReply(array &$untagged = null) : string
array
Will be filled with untagged response lines
string
Response text
parseResult(string $string, string $err_prefix = '') : int
string
Response text
string
Error message prefix
int
Response status
eof() : bool
bool
True if connection is closed
closeSocket()
setError($code, $msg = '')
startsWith(string $string, string $match, bool $error = false, bool $nonempty = false) : bool
Checks if command response line starts with specified prefix (or * BYE/BAD)
string
Response text
string
Prefix to match with (case-sensitive)
bool
Enables BYE/BAD checking
bool
Enables empty response checking
bool
True any check is true or connection is closed.
hasCapability($name)
getCapability(string $name) : mixed
string
Capability name
mixed
Capability values array for key=value pairs, true/false for others
clearCapability()
authenticate(string $user, string $pass, string $type = 'PLAIN') : resource
string
string
string
Authentication type (PLAIN/CRAM-MD5/DIGEST-MD5)
resource
Connection resourse on success, error code on error
login(string $user, $password) : resource
string
resource
Connection resourse on success, error code on error
getHierarchyDelimiter() : string
string
The delimiter
getNamespace() : array
array
Namespace data hash (personal, other, shared)
connect(string $host, string $user, string $password, array $options = null) : bool
string
Server hostname or IP
string
User name
string
Password
array
Connection and class options
bool
True on success, False on failure
set_prefs($prefs)
connected() : bool
bool
True if connection is active and user is logged in, False otherwise.
closeConnection()
select(string $mailbox, array $qresync_data = null) : boolean
string
Mailbox name
array
QRESYNC data (RFC5162)
boolean
True on success, false on error
status(string $mailbox, array $items = array()) : array
since | 0.5-beta |
---|---|
string
Mailbox name
array
Additional requested item names. By default
MESSAGES and UNSEEN are requested. Other defined
in RFC3501: UIDNEXT, UIDVALIDITY, RECENT
array
Status item-value hash
expunge(string $mailbox, string|array $messages = NULL) : boolean
string
Mailbox name
string|array
Message UIDs to expunge
boolean
True on success, False on error
close() : boolean
since | 0.5 |
---|---|
boolean
True on success, False on error
subscribe(string $mailbox) : boolean
string
Mailbox name
boolean
True on success, False on error
unsubscribe(string $mailbox) : boolean
string
Mailbox name
boolean
True on success, False on error
createFolder(string $mailbox) : bool
string
Mailbox name
bool
True on success, False on error
renameFolder($from, $to) : bool
bool
True on success, False on error
deleteFolder(string $mailbox) : boolean
string
Mailbox name
boolean
True on success, False on error
clearFolder(string $mailbox) : boolean
string
Mailbox name
boolean
True on success, False on error
listMailboxes(string $ref, string $mailbox, array $status_opts = array(), array $select_opts = array()) : array
string
Reference name
string
Mailbox name
array
(see self::_listMailboxes)
array
(see self::_listMailboxes)
array
List of mailboxes or hash of options if $status_opts argument
is non-empty.
listSubscribed(string $ref, string $mailbox, array $status_opts = array()) : array
string
Reference name
string
Mailbox name
array
(see self::_listMailboxes)
array
List of mailboxes or hash of options if $status_opts argument
is non-empty.
_listMailboxes(string $ref, string $mailbox, bool $subscribed = false, array $status_opts = array(), array $select_opts = array()) : array
string
Reference name
string
Mailbox name
bool
Enables returning subscribed mailboxes only
array
List of STATUS options (RFC5819: LIST-STATUS)
Possible: MESSAGES, RECENT, UIDNEXT, UIDVALIDITY, UNSEEN
array
List of selection options (RFC5258: LIST-EXTENDED)
Possible: SUBSCRIBED, RECURSIVEMATCH, REMOTE
array
List of mailboxes or hash of options if $status_ops argument
is non-empty.
countMessages(string $mailbox, $refresh = false) : int
string
Mailbox name
int
Number of messages, False on error
countRecent(string $mailbox) : int
string
Mailbox name
int
Number of messages, False on error
countUnseen(string $mailbox) : int
string
Mailbox name
int
Number of messages, False on error
id(array $items = array()) : array
since | 0.6 |
---|---|
array
Client identification information key/value hash
array
Server identification information key/value hash
enable(mixed $extension) : array|bool
since | 0.6 |
---|---|
mixed
Extension name to enable (or array of names)
array|bool
List of enabled extensions, False on error
sort(string $mailbox, string $field, string $add = '', bool $return_uid = false, string $encoding = 'US-ASCII') : \rcube_result_index
string
Mailbox name
string
Field to sort by (ARRIVAL, CC, DATE, FROM, SIZE, SUBJECT, TO)
string
Searching criteria
bool
Enables UID SORT usage
string
Character set
\rcube_result_index
Response data
thread(string $mailbox, string $algorithm = 'REFERENCES', string $criteria = '', bool $return_uid = false, string $encoding = 'US-ASCII') : \rcube_result_thread
string
Mailbox name
string
Threading algorithm (ORDEREDSUBJECT, REFERENCES, REFS)
string
Searching criteria
bool
Enables UIDs in result instead of sequence numbers
string
Character set
\rcube_result_thread
Thread data
search(string $mailbox, string $criteria, bool $return_uid = false, array $items = array()) : \rcube_result_index
string
Mailbox name
string
Searching criteria
bool
Enable UID in result instead of sequence ID
array
Return items (MIN, MAX, COUNT, ALL)
\rcube_result_index
Result data
index(string $mailbox, string|array $message_set, string $index_field = '', bool $skip_deleted = true, bool $uidfetch = false, bool $return_uid = false) : \rcube_result_index
string
Mailbox name
string|array
Searching criteria (list of messages to return)
string
Field to sort by (ARRIVAL, CC, DATE, FROM, SIZE, SUBJECT, TO)
bool
Makes that DELETED messages will be skipped
bool
Enables UID FETCH usage
bool
Enables returning UIDs instead of IDs
\rcube_result_index
Response data
fetchHeaderIndex($mailbox, $message_set, $index_field = '', $skip_deleted = true, $uidfetch = false, $return_uid = false)
UID2ID(string $mailbox, int $uid) : int
string
Mailbox name
int
Message unique identifier (UID)
int
Message sequence identifier
ID2UID(string $mailbox, $id) : int
string
Mailbox name
int
Message unique identifier
flag(string $mailbox, string|array $messages, string $flag) : bool
string
Mailbox name
string|array
Message UID(s)
string
Flag name
bool
True on success, False on failure
unflag(string $mailbox, string|array $messages, string $flag) : bool
string
Mailbox name
string|array
Message UID(s)
string
Flag name
bool
True on success, False on failure
modFlag(string $mailbox, string|array $messages, string $flag, string $mod = '+') : bool
string
Mailbox name
string|array
Message UID(s)
string
Flag name
string
Modifier [+|-]. Default: "+".
bool
True on success, False on failure
copy(string|array $messages, string $from, string $to) : bool
string|array
Message UID(s)
string
Mailbox name
string
Destination mailbox name
bool
True on success, False on failure
move(string|array $messages, string $from, string $to) : bool
string|array
Message UID(s)
string
Mailbox name
string
Destination mailbox name
bool
True on success, False on failure
fetch(string $mailbox, mixed $message_set, bool $is_uid = false, array $query_items = array(), string $mod_seq = null, bool $vanished = false) : array
since | 0.6 |
---|---|
string
Mailbox name
mixed
Message(s) sequence identifier(s) or UID(s)
bool
True if $message_set contains UIDs
array
FETCH command data items
string
Modification sequence for CHANGEDSINCE (RFC4551) query
bool
Enables VANISHED parameter (RFC5162) for CHANGEDSINCE query
array
List of rcube_message_header elements, False on error
fetchHeaders(string $mailbox, mixed $message_set, bool $is_uid = false, bool $bodystr = false, array $add_headers = array()) : bool|array
string
Mailbox name
mixed
Message(s) sequence identifier(s) or UID(s)
bool
True if $message_set contains UIDs
bool
Enable to add BODYSTRUCTURE data to the result
array
List of additional headers
bool|array
List of rcube_message_header elements, False on error
fetchHeader(string $mailbox, int $id, bool $is_uid = false, bool $bodystr = false, array $add_headers = array()) : bool|\rcube_message_header
string
Mailbox name
int
Message sequence identifier or UID
bool
True if $id is an UID
bool
Enable to add BODYSTRUCTURE data to the result
array
List of additional headers
bool|\rcube_message_header
Message data, False on error
sortHeaders($a, $field, $flag)
fetchMIMEHeaders($mailbox, $uid, $parts, $mime = true)
fetchPartHeader($mailbox, $id, $is_uid = false, $part = NULL)
handlePartBody($mailbox, $id, $is_uid = false, $part = '', $encoding = NULL, $print = NULL, $file = NULL, $formatted = false, $max_bytes)
append(string $mailbox, string|array &$message, array $flags = array(), string $date = null, bool $binary = false) : string|bool
string
Mailbox name
string|array
The message source string or array (of strings and file pointers)
array
Message flags
string
Message internal date
bool
Enable BINARY append (RFC3516)
string|bool
On success APPENDUID response (if available) or True, False on failure
appendFromFile(string $mailbox, string $path, string $headers = null, array $flags = array(), string $date = null, bool $binary = false) : string|bool
string
Mailbox name
string
Path to the file with message body
string
Message headers
array
Message flags
string
Message internal date
bool
Enable BINARY append (RFC3516)
string|bool
On success APPENDUID response (if available) or True, False on failure
getQuota() : array
array
Quota information
setACL(string $mailbox, string $user, mixed $acl) : boolean
since | 0.5-beta |
---|---|
string
Mailbox name
string
User name
mixed
ACL string or array
boolean
True on success, False on failure
deleteACL(string $mailbox, string $user) : boolean
since | 0.5-beta |
---|---|
string
Mailbox name
string
User name
boolean
True on success, False on failure
getACL(string $mailbox) : array
since | 0.5-beta |
---|---|
string
Mailbox name
array
User-rights array on success, NULL on error
listRights(string $mailbox, string $user) : array
since | 0.5-beta |
---|---|
string
Mailbox name
string
User name
array
List of user rights
myRights(string $mailbox) : array
since | 0.5-beta |
---|---|
string
Mailbox name
array
MYRIGHTS response on success, NULL on error
setMetadata(string $mailbox, array $entries) : boolean
since | 0.5-beta |
---|---|
string
Mailbox name
array
Entry-value array (use NULL value as NIL)
boolean
True on success, False on failure
deleteMetadata(string $mailbox, array $entries) : boolean
since | 0.5-beta |
---|---|
string
Mailbox name
array
Entry names array
boolean
True on success, False on failure
getMetadata(string $mailbox, array $entries, array $options = array()) : array
since | 0.5-beta |
---|---|
string
Mailbox name
array
Entries
array
Command options (with MAXSIZE and DEPTH keys)
array
GETMETADATA result on success, NULL on error
setAnnotation(string $mailbox, array $data) : boolean
since | 0.5-beta |
---|---|
string
Mailbox name
array
Data array where each item is an array with
three elements: entry name, attribute name, value
boolean
True on success, False on failure
deleteAnnotation(string $mailbox, array $data) : boolean
since | 0.5-beta |
---|---|
string
Mailbox name
array
Data array where each item is an array with
two elements: entry name and attribute name
boolean
True on success, False on failure
getAnnotation(string $mailbox, array $entries, array $attribs) : array
since | 0.5-beta |
---|---|
string
Mailbox name
array
Entries names
array
Attribs names
array
Annotations result on success, NULL on error
getStructure(string $mailbox, int $id, bool $is_uid = false) : \array/bool
since | 0.6 |
---|---|
string
Folder name
int
Message sequence number or UID
bool
True if $id is an UID
\array/bool
Body structure array or False on error.
getStructurePartData(array $structure, string $part) : array
array
Message structure (getStructure() result)
string
Message part identifier
array
Part data as hash array (type, encoding, charset, size)
getStructurePartArray($a, $part)
nextTag() : string
since | 0.5-beta |
---|---|
string
Command identifier
execute(string $command, array $arguments = array(), int $options) : mixed
since | 0.5-beta |
---|---|
string
IMAP command
array
Command arguments
int
Execution options
mixed
Response code or list of response code and data
tokenizeResponse(&$str, int $num) : mixed
since | 0.5-beta |
---|---|
int
Number of tokens to return
mixed
Tokens array or string if $num=1
r_implode($element)
compressMessageSet(array $messages, bool $force = false) : string
array
Message identifiers
bool
Forces compression of any size
string
Compressed sequence-set
uncompressMessageSet(string $messages) : array
string
Message identifiers
array
List of message identifiers
_xor($string, $string2)
flagsToStr(array $flags) : string
array
Flags (see self::flags)
string
Space-separated list of flags
strToTime(string $date) : int
string
Date string
int
Unix timestamp
parseCapability($str, $trusted = false)
escape(string $string, boolean $force_quotes = false) : string
todo |
lists |
---|
string
IMAP string
boolean
Forces string quoting (for atoms)
string
String atom, quoted-string or string literal
setDebug(boolean $debug, callback $handler = null)
since | 0.5-stable |
---|---|
boolean
New value for the debugging flag.
callback
Logging handler function
debug(string $message)
since | 0.5-stable |
---|---|
string
Debug mesage text.
ERROR_OK
ERROR_NO
ERROR_BAD
ERROR_BYE
ERROR_UNKNOWN
ERROR_COMMAND
ERROR_READONLY
COMMAND_NORESPONSE
COMMAND_CAPABILITY
COMMAND_LASTLINE
DEBUG_LINE_LENGTH
error :
errornum :
result :
resultcode :
selected :
data :
flags :
mupdate :
fp :
host :
logged :
capability :
capability_readed :
prefs :
cmd_tag :
cmd_num :
resourceid :
_debug :
_debug_handler :