extends |
Hm_IMAP_Cache |
|---|
public interface to IMAP commands
| Methods | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
public
|
__construct()
constructor
constructor |
# | ||||||||||||
public
|
connect(array $config): bool
connect to the imap server
connect to the imap server Parameters
Returnstrue on connection sucess |
# | ||||||||||||
public
|
disconnect(): void
close the IMAP connection
close the IMAP connection |
# | ||||||||||||
public
|
authenticate(string $username, string $password): bool
Authenticate the username/password
Authenticate the username/password Parameters
Returnstrue on successful login |
# | ||||||||||||
public
|
starttls(): void
attempt starttls
attempt starttls |
# | ||||||||||||
public
|
get_capability(): string
fetch IMAP server capability response
fetch IMAP server capability response Returnscapability response |
# | ||||||||||||
public
|
set_acl(string $mailbox_name, string $identifier, string $rights_modification): bool
Sets the Access Control List (ACL) for a specified mailbox.
Sets the Access Control List (ACL) for a specified mailbox. This function sends the The third argument can either:
For more information on ACLs, see RFC 4314: Access Control Lists (ACLs) in Internet Message Access Protocol (IMAP). Parameters
ReturnsTrue if the ACL was successfully set, false if an error occurred. |
# | ||||||||||||
public
|
delete_acl($mailbox_name, string $identifier): bool
Deletes an access control list (ACL) entry for a specified identifier on a given mailbox.
Deletes an access control list (ACL) entry for a specified identifier on a given mailbox. This function sends a DELETEACL command to remove any <identifier, rights> pair for the specified identifier from the access control list for the specified mailbox. For more information on ACLs, see RFC 4314: Access Control Lists (ACLs) in Internet Message Access Protocol (IMAP). Parameters
ReturnsReturns true on successful deletion of the ACL entry; otherwise, false. Throws
|
# | ||||||||||||
public
|
get_acl(string $mailbox_name): array
Retrieves the Access Control List (ACL) for a specified mailbox.
Retrieves the Access Control List (ACL) for a specified mailbox. This function sends a For more information on ACLs, see RFC 4314: Access Control Lists (ACLs) in Internet Message Access Protocol (IMAP). Parameters
ReturnsAn associative array where the keys are email addresses (or user identifiers), and the values are human-readable permissions (e.g., 'Read, Write'). |
# | ||||||||||||
public
|
get_special_use_mailboxes(string $type = false): array
special version of LIST to return just special use mailboxes
special version of LIST to return just special use mailboxes Parameters
Returnslist of special use folders |
# | ||||||||||||
public
|
get_mailbox_list(bool $lsub = false, $mailbox = '', $keyword = '*', $children_capability = true): array
get a list of mailbox folders
get a list of mailbox folders Parameters
Returnsassociative array of folder details |
# | ||||||||||||
public
|
preprocess_folders(array $result, string $mailbox, string $delim): array
Preprocess the folder list to determine if a folder has children
Preprocess the folder list to determine if a folder has children Parameters
Returnsthe processed folder list |
# | ||||||||||||
public
|
fsort($a, $b)
Sort a folder list with the inbox at the top
Sort a folder list with the inbox at the top |
# | ||||||||||||
public
|
get_namespaces(): array
get IMAP folder namespaces
get IMAP folder namespaces Returnslist of available namespace details |
# | ||||||||||||
public
|
select_mailbox(string $mailbox)
select a mailbox
select a mailbox Parameters
|
# | ||||||||||||
public
|
get_mailbox_status(string $mailbox, array $args = ['UNSEEN', 'UIDVALIDITY', 'UIDNEXT', 'MESSAGES', 'RECENT']): array
issue IMAP status command on a mailbox
issue IMAP status command on a mailbox Parameters
Returnslist of attribute values discovered |
# | ||||||||||||
public
|
mailbox_subscription(string $mailbox, string $action): boolean
Subscribe/Unsubscribe folder
Subscribe/Unsubscribe folder Parameters
Returnsfailure or success |
# | ||||||||||||
public
|
poll(): bool
use IMAP NOOP to poll for untagged server messages
use IMAP NOOP to poll for untagged server messages |
# | ||||||||||||
public
|
get_message_list(mixed $uids, bool $raw = false, $include_content_body = false): array
return a header list for the supplied message uids
return a header list for the supplied message uids Parameters
Returnslist of headers and values for the specified uids |
# | ||||||||||||
public
|
get_message_structure(int $uid): array
get the IMAP BODYSTRUCTURE of a message
get the IMAP BODYSTRUCTURE of a message Parameters
Returnsmessage structure represented as a nested array |
# | ||||||||||||
public
|
get_message_content(int $uid, string $message_part, int $max = false, mixed $struct = true): string
get content for a message part
get content for a message part Parameters
Returnsmessage content |
# | ||||||||||||
public
|
search(
string $target = 'ALL',
mixed $uids = false,
$terms = [],
$esearch = [],
bool $exclude_deleted = true,
bool $exclude_auto_bcc = true,
bool $only_auto_bcc = false,
): array
use IMAP SEARCH or ESEARCH
use IMAP SEARCH or ESEARCH Parameters
Returnslist of IMAP message UIDs that match the search |
# | ||||||||||||
public
|
get_message_headers(int $uid, string $message_part = false, $raw = false): array
get the headers for the selected message
get the headers for the selected message Parameters
Returnsassociate array of message headers |
# | ||||||||||||
public
|
start_message_stream(int $uid, string $message_part): int
start streaming a message part. returns the number of characters in the message
start streaming a message part. returns the number of characters in the message Parameters
Returnsthe size of the message queued up to stream |
# | ||||||||||||
public
|
read_stream_line(int $size = 1024): string
read a line from a message stream. Called until it returns
false will "stream" a message part content one line at a…
read a line from a message stream. Called until it returns false will "stream" a message part content one line at a time. useful for avoiding memory consumption when dealing with large attachments Parameters
Returnschunk of the streamed message |
# | ||||||||||||
public
|
sort_by_fetch(string $sort, bool $reverse, string $filter, string $uid_str = false): array
use FETCH to sort a list of uids when SORT is not available
use FETCH to sort a list of uids when SORT is not available Parameters
Returnslist of UIDs in the sort order |
# | ||||||||||||
public
|
delete_mailbox(string $mailbox): bool
delete an existing mailbox
delete an existing mailbox Parameters
Returnstru if the mailbox was deleted |
# | ||||||||||||
public
|
get_recursive_subfolders($parentFolder, $is_delete_action)
|
# | ||||||||||||
public
|
rename_mailbox(string $mailbox, string $new_mailbox): bool
rename and existing mailbox
rename and existing mailbox Parameters
Returnstrue if the rename operation worked |
# | ||||||||||||
public
|
create_mailbox(string $mailbox): bool
create a new mailbox
create a new mailbox Parameters
Returnstrue if the mailbox was created |
# | ||||||||||||
public
|
message_action(string $action, mixed $uids, string $mailbox = false, string $keyword = false)
perform an IMAP action on a message
perform an IMAP action on a message Parameters
|
# | ||||||||||||
public
|
append_start(string $mailbox, int $size, bool $seen = true, $draft = false)
start writing a message to a folder with IMAP APPEND
start writing a message to a folder with IMAP APPEND Parameters
|
# | ||||||||||||
public
|
append_feed(string $string): int
write a line to an active IMAP APPEND operation
write a line to an active IMAP APPEND operation Parameters
Returnslength written |
# | ||||||||||||
public
|
append_end(): bool
finish an IMAP APPEND operation
finish an IMAP APPEND operation Returnstrue on success |
# | ||||||||||||
public
|
convert_sequence_to_array(string $sequence)
convert a sequence string to an array
convert a sequence string to an array Parameters
|
# | ||||||||||||
public
|
convert_array_to_sequence(array $array): string
convert an array into a sequence string
convert an array into a sequence string Parameters
Returnsan IMAP sequence string |
# | ||||||||||||
public
|
decode_fld(string $string): string
decode mail fields to human readable text
decode mail fields to human readable text Parameters
Returnsdecoded field |
# | ||||||||||||
public
|
is_supported(string $extension): bool
check if an IMAP extension is supported by the server
check if an IMAP extension is supported by the server Parameters
Returnstrue if the extension is supported |
# | ||||||||||||
public
|
get_state(): string
returns current IMAP state
returns current IMAP state Returnsone of: disconnected = no IMAP server TCP connection connected = an IMAP server TCP connection exists authenticated = successfully authenticated to the IMAP server selected = a mailbox has been selected |
# | ||||||||||||
public
|
show_debug(bool $full = false, bool $return = false, bool $list = false)
output IMAP session debug info
output IMAP session debug info Parameters
|
# | ||||||||||||
public
|
search_bodystructure(array $struct, array $search_flds, $all = true, $res = []): array
search a nested BODYSTRUCTURE response for a specific part
search a nested BODYSTRUCTURE response for a specific part Parameters
Returnsarray of all matching parts from the message |
# | ||||||||||||
public
|
get_quota(string $quota_root = ''): array
use the IMAP GETQUOTA command to fetch quota information
use the IMAP GETQUOTA command to fetch quota information Parameters
Returnslist of quota details |
# | ||||||||||||
public
|
get_quota_root(string $mailbox): array
use the IMAP GETQUOTAROOT command to fetch quota information about a mailbox
use the IMAP GETQUOTAROOT command to fetch quota information about a mailbox Parameters
Returnslist of quota details |
# | ||||||||||||
public
|
enable(): array
use the ENABLE extension to tell the IMAP server what extensions we support
use the ENABLE extension to tell the IMAP server what extensions we support Returnslist of supported extensions that can be enabled |
# | ||||||||||||
public
|
unselect_mailbox(): bool
unselect the selected mailbox
unselect the selected mailbox Returnstrue on success |
# | ||||||||||||
public
|
id(): array
use the ID extension
use the ID extension Returnslist of server properties on success |
# | ||||||||||||
public
|
get_message_sort_order(
string $sort = 'ARRIVAL',
bool $reverse = true,
string $filter = 'ALL',
$terms = [],
$exclude_deleted = true,
$exclude_auto_bcc = false,
$only_auto_bcc = false,
): array
use the SORT extension to get a sorted UID list and also perform term search if available
use the SORT extension to get a sorted UID list and also perform term search if available Parameters
Returnslist of IMAP message UIDs |
# | ||||||||||||
public
|
google_search($search_str): array
search using the Google X-GM-RAW IMAP extension
search using the Google X-GM-RAW IMAP extension Returnslist of IMAP UIDs that match the search |
# | ||||||||||||
public
|
enable_compression(): void
attempt enable IMAP COMPRESS extension
attempt enable IMAP COMPRESS extension |
# | ||||||||||||
public
|
get_first_message_part(int $uid, string $type, string $subtype = false, array $struct = false): string
return the formatted message content of the first part that matches the supplied MIME type
return the formatted message content of the first part that matches the supplied MIME type Parameters
Returnsformatted message content, bool false if no matching part is found |
# | ||||||||||||
public
|
get_mailbox_page(
string $mailbox,
string $sort,
$rev,
string $filter,
int $offset = 0,
int $limit = 0,
string $keyword = false,
$trusted_senders = [],
$include_preview = false,
): array
return a list of headers and UIDs for a page of a mailbox
return a list of headers and UIDs for a page of a mailbox Parameters
Returnslist of headers |
# | ||||||||||||
public
|
get_folder_list_by_level(
string $level = '',
$only_subscribed = false,
$with_input = false,
$count_children = false,
): array
return all the folders contained at a hierarchy level, and if possible, if they have sub-folders
return all the folders contained at a hierarchy level, and if possible, if they have sub-folders Parameters
Returnslist of matching folders |
# | ||||||||||||
protected
|
server_supports_custom_headers(): boolean
Test if the server supports searching by custom headers.
Test if the server supports searching by custom headers. This function sends a test search command to check if the server supports searching by custom headers (e.g., X-Auto-Bcc). If the server does not support this feature, it will return false. Reference: Stalwart's current limitation on searching by custom headers discussed in the following GitHub thread: https://github.com/stalwartlabs/mail-server/discussions/477 Note: This function should be removed once Stalwart starts supporting custom headers. Returnstrue if the server supports searching by custom headers. |
# | ||||||||||||
public
|
server_support_children_capability()
|
# | ||||||||||||
| Methods inherited from Hm_IMAP_Base |
|---|
parse_line(), fgets(), get_response(), send_command(), check_response(), utf7_decode(), utf7_encode(), input_validate(), is_clean(), apply_config() |
| Properties | |||
|---|---|---|---|
public
|
|
$max_read = false
|
# |
public
|
|
$verify_peer_name = false
|
# |
public
|
|
$verify_peer = false
|
# |
public
|
|
$server = '127.0.0.1'
|
# |
public
|
|
$port = 143
|
# |
public
|
|
$tls = false
|
# |
public
|
|
$read_only = false
|
# |
public
|
|
$utf7_folders = true
|
# |
public
|
|
$auth = false
|
# |
public
|
|
$search_charset = ''
|
# |
public
|
|
$sort_speedup = true
|
# |
public
|
|
$use_cache = true
|
# |
public
|
|
$folder_max = 50000
|
# |
public
|
|
$max_history = 1000
|
# |
public
|
|
$default_delimiter = '/'
|
# |
public
|
|
$default_prefix = ''
|
# |
public
|
|
$blacklisted_extensions = []
|
# |
public
|
|
$cache_limit = 100
|
# |
public
|
|
$no_caps = false
|
# |
public
|
|
$server_type = 'IMAP'
|
# |
public
|
|
$app_name = 'Hm_IMAP'
|
# |
public
|
|
$app_version = '3.0'
|
# |
public
|
|
$app_vendor = 'Cypht Development Group'
|
# |
public
|
|
$app_support_url = 'https://cypht.org/#contact'
|
# |
public
|
|
$con_error_msg = ''
|
# |
public
|
|
$con_error_num = 0
|
# |
public
|
|
$banner = ''
|
# |
public
|
|
$selected_mailbox = false
|
# |
public
|
|
$special_use_mailboxes = [
'\All' => false,
'\Archive' => false,
'\Drafts' => false,
'\Flagged' => false,
'\Junk' => false,
'\Sent' => false,
'\Trash' => false,
]
|
# |
public
|
|
$folder_state = false
|
# |
protected
|
|
$list_sub_folders = []
|
# |