Overview

Packages

  • framework
    • api
    • auth
    • cache
    • config
    • crypt
    • db
    • dispatch
    • format
    • module
    • modules
    • oauth2
    • output
    • request
    • servers
    • session
    • setup
    • webdav
  • modules
    • 2fa
      • handler
      • output
    • account
      • handler
      • output
    • api
      • login
        • functions
        • handler
    • calendar
      • handler
      • lib
      • output
    • carddav
      • contacts
        • functions
        • handler
    • contacts
      • handler
      • lib
      • output
    • core
      • handler
      • output
    • desktop
      • notifications
    • developer
      • handler
      • output
    • dynamic
      • login
        • handler
        • lib
        • output
    • feeds
      • handler
      • lib
      • output
    • github
      • handler
      • lib
      • output
    • gmail
      • contacts
        • handler
        • lib
    • helloworld
      • handler
      • output
    • history
      • handler
      • output
    • idletimer
      • handler
      • output
    • imap
      • folders
        • handler
        • output
      • handler
      • lib
      • output
    • inline
      • message
        • handler
        • output
    • keyboard
      • shortcuts
        • handler
        • output
    • ldap
      • contacts
        • handler
        • lib
        • output
    • local
      • contacts
        • handler
        • output
    • nasa
      • handler
      • output
    • nux
      • handler
      • lib
      • output
    • pgp
      • handler
      • output
    • pop3
      • handler
      • lib
      • output
    • profile
      • handler
      • output
    • profiles
      • lib
    • recaptcha
      • handler
      • output
    • recover
      • settings
        • handler
        • output
    • savedsearches
      • handler
      • lib
      • output
    • site
      • handler
    • smtp
      • handler
      • lib
      • output
    • tags
      • handler
      • libs
      • output
    • themes
      • handler
      • output
    • wordpress
      • handler
      • output
  • None

Classes

  • Hm_IMAP
  • Hm_IMAP_Base
  • Hm_IMAP_Cache
  • Hm_IMAP_List
  • Hm_IMAP_Parser
  • Hm_IMAP_Struct
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo

Class Hm_IMAP

public interface to IMAP commands

Hm_IMAP_Base
Extended by Hm_IMAP_Parser
Extended by Hm_IMAP_Cache
Extended by Hm_IMAP
Package: modules\imap\lib
Located at imap/hm-imap.php
Methods summary
public
# __construct( )

constructor

constructor

public boolean
# connect( array $config )

connect to the imap server

connect to the imap server

Parameters

$config
list of configuration options for this connections

Returns

boolean
true on connection sucess
public
# disconnect( )

close the IMAP connection

close the IMAP connection

public boolean
# authenticate( string $username, string $password )

authenticate the username/password

authenticate the username/password

Parameters

$username
IMAP login name
$password
IMAP password

Returns

boolean
true on sucessful login
public
# starttls( )

attempt starttls

attempt starttls

public string
# get_capability( )

fetch IMAP server capability response

fetch IMAP server capability response

Returns

string
capability response
public array
# get_special_use_mailboxes( string $type = false )

special version of LIST to return just special use mailboxes

special version of LIST to return just special use mailboxes

Parameters

$type
type of special folder to return (sent, all, trash, flagged, junk)

Returns

array
list of special use folders
public array
# get_mailbox_list( boolean $lsub = false, $mailbox = '', $keyword = '*' )

get a list of mailbox folders

get a list of mailbox folders

Parameters

$lsub
flag to limit results to subscribed folders only
$mailbox
$keyword

Returns

array
associative array of folder details
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 array
# get_namespaces( )

get IMAP folder namespaces

get IMAP folder namespaces

Returns

array
list of available namespace details
public
# select_mailbox( string $mailbox )

select a mailbox

select a mailbox

Parameters

$mailbox
the mailbox to attempt to select
public array
# get_mailbox_status( string $mailbox, array $args = array('UNSEEN', 'UIDVALIDITY', 'UIDNEXT', 'MESSAGES', 'RECENT') )

issue IMAP status command on a mailbox

issue IMAP status command on a mailbox

Parameters

$mailbox
IMAP mailbox to check
$args
list of properties to fetch

Returns

array
list of attribute values discovered
public boolean
# poll( )

use IMAP NOOP to poll for untagged server messages

use IMAP NOOP to poll for untagged server messages

Returns

boolean
public array
# get_message_list( mixed $uids, boolean $raw = false )

return a header list for the supplied message uids

return a header list for the supplied message uids

Parameters

$uids
an array of uids or a valid IMAP sequence set as a string
$raw
flag to disable decoding header values

Returns

array
list of headers and values for the specified uids

Todo

refactor. abstract header line continuation parsing for re-use
public array
# get_message_structure( integer $uid )

get the IMAP BODYSTRUCTURE of a message

get the IMAP BODYSTRUCTURE of a message

Parameters

$uid
IMAP UID of the message

Returns

array
message structure represented as a nested array
private array
# get_raw_bodystructure( integer $uid )

get the raw IMAP BODYSTRUCTURE response

get the raw IMAP BODYSTRUCTURE response

Parameters

$uid
IMAP UID of the message

Returns

array
low-level parsed message structure
private array
# parse_bodystructure_response( array $result )

New BODYSTRUCTURE parsing routine

New BODYSTRUCTURE parsing routine

Parameters

$result
low-level IMAP response

Returns

array
public string
# get_message_content( integer $uid, string $message_part, boolean $max = false, integer $struct = true, mixed $struct,… )

get content for a message part

get content for a message part

Parameters

$uid
a single IMAP message UID
$message_part
the IMAP message part number
$max
$raw flag to enabled fetching the entire message as text
$struct
$max maximum read length to allow.
$struct,…

a message part structure array for decoding and charset conversion. bool true for auto discovery

Returns

string
message content
public array
# search( string $target = 'ALL', mixed $uids = false, string $terms = array(), string $esearch = array(), boolean $exclude_deleted = true, boolean $exclude_auto_bcc = true, boolean $only_auto_bcc = false )

use IMAP SEARCH or ESEARCH /** search a field for a keyword

use IMAP SEARCH or ESEARCH /** search a field for a keyword

Parameters

$target
message types to search. can be ALL, UNSEEN, ANSWERED, etc
$uids
an array of uids or a valid IMAP sequence set as a string (or false for ALL)
$terms
$fld optional field to search
$esearch
$term optional search term
$exclude_deleted
extra argument to exclude messages with the deleted flag
$exclude_auto_bcc
don't include auto-bcc'ed messages
$only_auto_bcc
only include auto-bcc'ed messages

Returns

array
list of IMAP message UIDs that match the search
public array
# get_message_headers( integer $uid, string $message_part = false, $raw = false )

get the headers for the selected message

get the headers for the selected message

Parameters

$uid
IMAP message UID
$message_part
IMAP message part number
$raw

Returns

array
associate array of message headers
public integer
# start_message_stream( integer $uid, string $message_part )

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

$uid
IMAP message UID
$message_part
IMAP message part number

Returns

integer
the size of the message queued up to stream
public string
# read_stream_line( integer $size = 1024 )

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

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

$size
chunk size to read using fgets

Returns

string
chunk of the streamed message
public array
# sort_by_fetch( string $sort, boolean $reverse, string $filter, string $uid_str = false )

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

$sort
the sort field
$reverse
flag to reverse the results
$filter
IMAP message type (UNSEEN, ANSWERED, DELETED, etc)
$uid_str
IMAP sequence set string or false

Returns

array
list of UIDs in the sort order
public boolean
# delete_mailbox( string $mailbox )

delete an existing mailbox

delete an existing mailbox

Parameters

$mailbox
IMAP mailbox name to delete

Returns

boolean
tru if the mailbox was deleted
public boolean
# rename_mailbox( string $mailbox, string $new_mailbox )

rename and existing mailbox

rename and existing mailbox

Parameters

$mailbox
IMAP mailbox to rename
$new_mailbox
new name for the mailbox

Returns

boolean
true if the rename operation worked
public boolean
# create_mailbox( string $mailbox )

create a new mailbox

create a new mailbox

Parameters

$mailbox
IMAP mailbox name

Returns

boolean
true 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

$action

action to perform, can be one of READ, UNREAD, FLAG, UNFLAG, ANSWERED, DELETE, UNDELETE, EXPUNGE, or COPY

$uids
an array of uids or a valid IMAP sequence set as a string
$mailbox
destination IMAP mailbox name for operations the require one
$keyword
optional custom keyword flag
public
# append_start( string $mailbox, integer $size, boolean $seen = true )

start writing a message to a folder with IMAP APPEND

start writing a message to a folder with IMAP APPEND

Parameters

$mailbox
IMAP mailbox name
$size
size of the message to be written
$seen

flag to mark the message seen $return bool true on success

public integer
# append_feed( string $string )

write a line to an active IMAP APPEND operation

write a line to an active IMAP APPEND operation

Parameters

$string
line to write

Returns

integer
length written
public boolean
# append_end( )

finish an IMAP APPEND operation

finish an IMAP APPEND operation

Returns

boolean
true on success
public
# convert_sequence_to_array( string $sequence )

convert a sequence string to an array

convert a sequence string to an array

Parameters

$sequence
an IMAP sequence string

Returns


$array list of ids
public string
# convert_array_to_sequence( array $array )

convert an array into a sequence string

convert an array into a sequence string

Parameters

$array
list of ids

Returns

string
an IMAP sequence string
public string
# decode_fld( string $string )

decode mail fields to human readable text

decode mail fields to human readable text

Parameters

$string
field to decode

Returns

string
decoded field
public boolean
# is_supported( string $extension )

check if an IMAP extension is supported by the server

check if an IMAP extension is supported by the server

Parameters

$extension
name of an extension

Returns

boolean
true if the extension is supported
public string
# get_state( )

returns current IMAP state

returns current IMAP state

Returns

string

one 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 void/string
# show_debug( boolean $full = false, boolean $return = false, boolean $list = false )

output IMAP session debug info

output IMAP session debug info

Parameters

$full
flag to enable full IMAP response display
$return
flag to return the debug results instead of printing them
$list
flag to return array

Returns

void/string
public array
# search_bodystructure( array $struct, string $search_flds, array $all = true, $res = array() )

search a nested BODYSTRUCTURE response for a specific part

search a nested BODYSTRUCTURE response for a specific part

Parameters

$struct
the structure to search
$search_flds
$search_term the search term
$all
$search_flds list of fields to search for the term
$res

Returns

array
array of all matching parts from the message
public array
# get_quota( string $quota_root = '' )

use the IMAP GETQUOTA command to fetch quota information

use the IMAP GETQUOTA command to fetch quota information

Parameters

$quota_root
named quota root to fetch

Returns

array
list of quota details
public array
# get_quota_root( string $mailbox )

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

$mailbox
IMAP folder to check

Returns

array
list of quota details
public array
# enable( )

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

Returns

array
list of supported extensions that can be enabled
public boolean
# unselect_mailbox( )

unselect the selected mailbox

unselect the selected mailbox

Returns

boolean
true on success
public array
# id( )

use the ID extension

use the ID extension

Returns

array
list of server properties on success
public array
# get_message_sort_order( string $sort = 'ARRIVAL', boolean $reverse = true, string $filter = 'ALL', $esort = array() )

use the SORT extension to get a sorted UID list

use the SORT extension to get a sorted UID list

Parameters

$sort
sort order. can be one of ARRIVAL, DATE, CC, TO, SUBJECT, FROM, or SIZE
$reverse
flag to reverse the sort order
$filter
can be one of ALL, SEEN, UNSEEN, ANSWERED, UNANSWERED, DELETED, UNDELETED, FLAGGED, or UNFLAGGED
$esort

Returns

array
list of IMAP message UIDs
public array
# google_search( string $search_str )

search using the Google X-GM-RAW IMAP extension

search using the Google X-GM-RAW IMAP extension

Parameters

$search_str
$start_str formatted search string like "has:attachment in:unread"

Returns

array
list of IMAP UIDs that match the search
public
# enable_compression( )

attempt enable IMAP COMPRESS extension

attempt enable IMAP COMPRESS extension

Todo:

currently does not work ...
public string
# get_first_message_part( integer $uid, string $type, string $subtype = false, $struct = false )

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

$uid
IMAP UID value for the message
$type
Primary MIME type like "text"
$subtype
Secondary MIME type like "plain"
$struct

Returns

string
formatted message content, bool false if no matching part is found
public array
# get_mailbox_page( string $mailbox, string $sort, string $rev, integer $filter, integer $offset = 0, $limit = 0 )

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

$mailbox
the mailbox to access
$sort
sort order. can be one of ARRIVAL, DATE, CC, TO, SUBJECT, FROM, or SIZE
$rev
$filter type of messages to include (UNSEEN, ANSWERED, ALL, etc)
$filter
$limit max number of messages to return
$offset
offset from the first message in the list
$limit

Returns

array
list of headers
public array
# get_folder_list_by_level( string $level = '' )

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

$level
mailbox name or empty string for the top level

Returns

array
list of matching folders
Methods inherited from Hm_IMAP_Cache
bust_cache(), cache_return_val(), check_cache(), collect_cache_entries_to_prune(), dump_cache(), load_cache(), prune_cache(), update_cache_data()
Methods inherited from Hm_IMAP_Parser
build_list_commands(), build_qresync_params(), check_mailbox_state_change(), flag_match(), get_adjacent_response_value(), get_flag_values(), parse_esearch_response(), parse_extensions_from_capability(), parse_quota_response(), parse_status_response(), parse_untagged_responses()
Methods inherited from Hm_IMAP_Base
apply_config(), check_response(), fgets(), get_response(), input_validate(), is_clean(), parse_line(), send_command(), utf7_decode(), utf7_encode()
Properties summary
public boolean $max_read
# false
public boolean $verify_peer_name
# false
public boolean $verify_peer
# false
public string $server
# '127.0.0.1'
public integer $port
# 143
public boolean $tls
# false
public boolean $read_only
# false
public boolean $utf7_folders
# true
public boolean $auth
# false
public string $search_charset
# ''
public boolean $sort_speedup
# true
public boolean $use_cache
# true
public integer $folder_max
# 50000
public integer $max_history
# 1000
public string $default_delimiter
# '/'
public string $default_prefix
# ''
public array $blacklisted_extensions
# array()
public integer $cache_limit
# 100
public boolean $no_caps
# false
public string $app_name
# 'Hm_IMAP'
public string $app_version
# '3.0'
public string $app_vendor
# 'Hastymail Development Group'
public string $app_support_url
# 'http://hastymail.org/contact_us/'
public string $con_error_msg
# ''
public integer $con_error_num
# 0
public boolean $selected_mailbox
# false
public array $special_use_mailboxes
# array( '\All' => false, '\Archive' => false, '\Drafts' => false, '\Flagged' => false, '\Junk' => false, '\Sent' => false, '\Trash' => false )
private string $state
# 'disconnected'
private integer $stream_size
# 0
public boolean $folder_state
# false
Properties inherited from Hm_IMAP_Base
$cache_data, $cached_response, $capability, $client_extensions, $command_count, $commands, $config, $current_command, $debug, $declared_extensions, $enabled_extensions, $handle, $literal_overflow, $responses, $server_id, $struct_object, $supported_extensions
Cypht Documentation API documentation generated by ApiGen