/functions/imap_general.php

Description

imap_general.php

This implements all functions that do general IMAP functions.

Includes
require_once (SM_PATH.'functions/rfc822address.php') (line 17)

Includes..

Functions
map_yp_alias (line 1505)

This is an example that gets IMAP servers from yellowpages (NIS).

you can simple put map:map_yp_alias in your $imap_server_address in config.php use your own function instead map_yp_alias to map your LDAP whatever way to find the users IMAP server.

Requires access to external ypmatch program FIXME: it can be implemented in php yp extension or pecl (since php 5.1.0)

  • since: 1.3.0
string map_yp_alias (string $username)
  • string $username
parseAddress (line 1271)

OBSOLETE FUNCTION should be removed after mailbox_display,

printMessage function is adapted $addr_ar = array(), $group = '' and $host='' arguments are used in 1.4.0

  • deprecated: See Rfc822Address.php
  • since: 1.4.0
void parseAddress (string $address, [integer $max = 0])
  • string $address
  • integer $max
sqimap_append (line 1380)

Saves a message to a given folder -- used for saving sent messages

string sqimap_append (stream $imap_stream,  $sMailbox, $length $length, string $sent_folder)
  • stream $imap_stream
  • string $sent_folder
  • $length $length
  • $sMailbox
sqimap_append_checkresponse (line 1409)

Displays error messages, if there are errors in responses to commands issues by sqimap_append() and sqimap_append_done() functions.

  • since: 1.5.1 and 1.4.5
bool sqimap_append_checkresponse (string $response, string $sMailbox, [ $sid = ''], [ $query = ''])
  • string $response
  • string $sMailbox
  • $sid
  • $query
sqimap_append_done (line 1393)
void sqimap_append_done (stream $imap_stream, [ $sMailbox = ''], string $folder)
  • string $folder: (since 1.3.2)
  • stream $imap_stream: imap_stream
  • $sMailbox
sqimap_capability (line 1081)

Retrieve the CAPABILITY string from the IMAP server.

If capability is set, returns only that specific capability, else returns array of all capabilities.

  • return: (string if $capability is set and found, false, if $capability is set and not found, array if $capability not set)
mixed sqimap_capability (stream $imap_stream, [string $capability = ''], [boolean $bUseCache = true])
  • stream $imap_stream
  • string $capability: (since 1.3.0)
  • boolean $bUseCache: (since 1.5.1) Controls use of capability data stored in session
sqimap_create_stream (line 690)

Connects to the IMAP server and returns a resource identifier for use with

the other SquirrelMail IMAP functions. Does NOT login!

  • return: resource identifier
  • since: 1.5.0 (usable only in 1.5.1 or later)
imap-stream sqimap_create_stream (string $server, int $port, [integer $tls = 0], [array $stream_options = array()])
  • integer $tls: whether to use plain text(0), TLS(1) or STARTTLS(2) when connecting. Argument was boolean before 1.5.1.
  • array $stream_options: Stream context options, see config_local.php for more details (OPTIONAL)
  • string $server: server hostname of IMAP server
  • int $port: port port number to connect to
sqimap_encode_mailbox_name (line 1242)

This encodes a mailbox name for use in IMAP commands.

  • return: the encoded mailbox string
  • since: 1.5.0
string sqimap_encode_mailbox_name (string $what)
  • string $what: the mailbox to encode
sqimap_error_box (line 368)

Function to display an error related to an IMAP query.

  • since: 1.5.0
void sqimap_error_box (string $title, [string $query = ''], [string $message_title = ''], [string $message = ''], [string $link = ''])
  • string $link: an optional link to try again
  • string $title: title the caption of the error box
  • string $query: query the query that went wrong
  • string $message_title: message_title optional message title
  • string $message: message optional error message
sqimap_fgets (line 242)

Custom fgets function: gets a line from the IMAP server, no matter how big it may be.

  • return: a line
  • since: 1.2.8
string sqimap_fgets (stream $imap_stream)
  • stream $imap_stream: the stream to read from
sqimap_fread (line 271)
  • since: 1.4.1
string sqimap_fread (stream $imap_stream, integer $iSize, [boolean $filter = false], [mixed $outputstream = false], [boolean $no_return = false])
  • stream $imap_stream
  • integer $iSize
  • boolean $filter
  • mixed $outputstream: stream or 'php://stdout' string
  • boolean $no_return: controls data returned by function
sqimap_get_delimiter (line 1120)

Returns the delimiter between mailboxes: INBOX/Test, or INBOX.Test

string sqimap_get_delimiter ([stream $imap_stream = false])
  • stream $imap_stream
sqimap_get_namespace (line 1178)

Retrieves the namespaces from the IMAP server.

NAMESPACE is an IMAP extension defined in RFC 2342.

array sqimap_get_namespace (stream $imap_stream)
  • stream $imap_stream
sqimap_get_num_messages (line 1257)

Gets the number of messages in the current mailbox.

OBSOLETE use sqimap_status_messages instead.

  • deprecated:
void sqimap_get_num_messages (stream $imap_stream, string $mailbox)
  • stream $imap_stream: imap stream
  • string $mailbox
sqimap_get_user_server (line 1485)

Allows mapping of IMAP server address with custom function

see map_yp_alias()

  • since: 1.3.0
string sqimap_get_user_server (string $imap_server, string $username)
  • string $imap_server: imap server address or mapping
  • string $username
sqimap_login (line 831)

Logs the user into the IMAP server. If $hide is set, no error messages will be displayed (if set to 1, just exits, if set to 2, returns FALSE).

This function returns the IMAP connection handle.

  • return: The IMAP connection stream, or if the connection fails, FALSE if $hide is set to 2 or an error string if $hide is set to 3.
mixed sqimap_login (string $username, string $password, string $imap_server_address, integer $imap_port, int $hide, [array $stream_options = array()])
  • string $username: user name
  • string $password: password encrypted with onetimepad. Since 1.5.2 function can use internal password functions, if parameter is set to boolean false.
  • string $imap_server_address: address of imap server
  • integer $imap_port: port of imap server
  • int $hide: controls display connection errors:
    1. = do not hide
    2. = show no errors (just exit)
    3. = show no errors (return FALSE)
    4. = show no errors (return error string)
  • array $stream_options: Stream context options, see config_local.php for more details (OPTIONAL)
sqimap_logout (line 1063)

Simply logs out the IMAP session

void sqimap_logout (stream $imap_stream)
  • stream $imap_stream: the IMAP connection to log out.
sqimap_parse_namespace (line 1204)

Parses a NAMESPACE response and returns an array with the available personal, users and shared namespaces.

  • return: The returned array has the following format:
     array(
       'personal' => array(
           0 => array('prefix'=>'INBOX.','delimiter' =>'.'),
           1 => ...
        ),
        'users' => array(..
        ),
        'shared' => array( ..
        )
     )
    Note that if a namespace is not defined in the server, then the corresponding array will be empty.
array sqimap_parse_namespace ( &$input, string $input)
  • string $input
  • &$input
sqimap_prepare_pipelined_query (line 152)
  • since: 1.5.0
void sqimap_prepare_pipelined_query (mixed $new_query,  &$tag,  &$aQuery, boolean $unique_id, string $tag, array $aQuery)
  • mixed $new_query
  • string $tag
  • array $aQuery
  • boolean $unique_id: see sqimap_session_id()
  • &$tag
  • &$aQuery
sqimap_read_data (line 666)
void sqimap_read_data (stream $imap_stream, string $tag_uid, boolean $handle_errors,  &$response,  &$message, [string $query = ''], [boolean $filter = false], [mixed $outputstream = false], [boolean $no_return = false], array $response, array $message)
  • stream $imap_stream: imap string
  • string $tag_uid
  • boolean $handle_errors
  • array $response
  • array $message
  • string $query: (since 1.2.5)
  • boolean $filter: (since 1.4.1) see sqimap_fread()
  • mixed $outputstream: (since 1.4.1) see sqimap_fread()
  • boolean $no_return: (since 1.4.1) see sqimap_fread()
  • &$response
  • &$message
sqimap_read_data_list (line 336)

Obsolete function, inform plugins that use it

  • deprecated: (since 1.5.0) use sqimap_run_command or sqimap_run_command_list instead
  • since: 1.1.3
void sqimap_read_data_list (stream $imap_stream, string $tag, boolean $handle_errors,  &$response,  &$message, [string $query = ''], array $response, array $message)
  • stream $imap_stream
  • string $tag
  • boolean $handle_errors
  • array $response
  • array $message
  • string $query
  • &$response
  • &$message
sqimap_retrieve_imap_response (line 406)

Reads the output from the IMAP stream. If handle_errors is set to true, this will also handle all errors that are received. If it is not set, the errors will be sent back through $response and $message.

  • since: 1.5.0
void sqimap_retrieve_imap_response (stream $imap_stream, string $tag, boolean $handle_errors,  &$response,  &$message, [string $query = ''], [boolean $filter = false], [mixed $outputstream = false], [boolean $no_return = false], array $response, array $message)
  • stream $imap_stream: imap stream
  • string $tag
  • boolean $handle_errors: handle errors internally or send them in $response and $message.
  • array $response
  • array $message
  • string $query: command that can be printed if something fails
  • boolean $filter: see sqimap_fread()
  • mixed $outputstream: see sqimap_fread()
  • boolean $no_return: see sqimap_fread()
  • &$response
  • &$message
sqimap_run_command (line 91)
  • return: returns false on imap error. displays error message if imap stream is not available.
  • since: 1.2.3
mixed sqimap_run_command (stream $imap_stream, string $query, boolean $handle_errors,  &$response,  &$message, [boolean $unique_id = false], [boolean $filter = false], [mixed $outputstream = false], [boolean $no_return = false], array $response, array $message)
  • stream $imap_stream: imap connection resource
  • string $query: imap command
  • boolean $handle_errors: see sqimap_retrieve_imap_response()
  • array $response: empty string, if return = false
  • array $message: empty string, if return = false
  • boolean $unique_id: (since 1.3.0) see sqimap_session_id()
  • boolean $filter: (since 1.4.1 and 1.5.0) see sqimap_fread()
  • mixed $outputstream: (since 1.4.1 and 1.5.0) see sqimap_fread()
  • boolean $no_return: (since 1.4.1 and 1.5.0) see sqimap_fread()
  • &$response
  • &$message
sqimap_run_command_list (line 52)

Both send a command and accept the result from the command.

This is to allow proper session number handling.

  • return: returns false on imap error. displays error message if imap stream is not available.
  • since: 1.2.3
mixed sqimap_run_command_list (stream $imap_stream, string $query, boolean $handle_errors,  &$response,  &$message, [boolean $unique_id = false], array $response, array $message)
  • stream $imap_stream: imap connection resource
  • string $query: imap command
  • boolean $handle_errors: see sqimap_retrieve_imap_response()
  • array $response
  • array $message
  • boolean $unique_id: (since 1.3.0) see sqimap_session_id().
  • &$response
  • &$message
sqimap_run_pipelined_command (line 172)
  • since: 1.5.0
void sqimap_run_pipelined_command (stream $imap_stream, array $aQueryList, boolean $handle_errors,  &$aServerResponse,  &$aServerMessage, [boolean $unique_id = false], [boolean $filter = false], [mixed $outputstream = false], [boolean $no_return = false], array $aServerResponse, array $aServerMessage)
  • stream $imap_stream: imap stream
  • array $aQueryList
  • boolean $handle_errors
  • array $aServerResponse
  • array $aServerMessage
  • boolean $unique_id: see sqimap_session_id()
  • boolean $filter: see sqimap_fread()
  • mixed $outputstream: see sqimap_fread()
  • boolean $no_return: see sqimap_fread()
  • &$aServerResponse
  • &$aServerMessage
sqimap_session_id (line 29)

Generates a new session ID by incrementing the last one used; this ensures that each command has a unique ID.

  • return: IMAP session id of the form 'A000'.
  • since: 1.2.0
string sqimap_session_id ([bool $unique_id = FALSE])
  • bool $unique_id: (since 1.3.0) controls use of unique identifiers/message sequence numbers in IMAP commands. See IMAP rfc 'UID command' chapter.
sqimap_status_messages (line 1327)

Returns the status items of a mailbox.

Default it returns MESSAGES,UNSEEN and RECENT Supported status items are MESSAGES, UNSEEN, RECENT (since 1.4.0), UIDNEXT (since 1.5.1) and UIDVALIDITY (since 1.5.1)

  • since: 1.3.2
array sqimap_status_messages (stream $imap_stream, string $mailbox, [array $aStatusItems = array('MESSAGES','UNSEEN','RECENT')])
  • stream $imap_stream: imap stream
  • string $mailbox: mail folder
  • array $aStatusItems: status items
sqimap_unseen_messages (line 1311)

Returns the number of unseen messages in this folder.

obsoleted by sqimap_status_messages ! Arguments differ in 1.0.x

  • deprecated:
integer sqimap_unseen_messages (stream $imap_stream, string $mailbox)
  • stream $imap_stream
  • string $mailbox
_adaptAddress (line 1293)

OBSOLETE FUNCTION should be removed after mailbox_display, printMessage function is adapted

callback function used for formating of addresses array in parseAddress() function

  • deprecated:
  • since: 1.5.1
void _adaptAddress ( &$aAddr, integer $k, array $aAddr)
  • array $aAddr
  • integer $k: array key
  • &$aAddr

Documentation generated on Sat, 25 Oct 2014 04:18:14 +0200 by phpDocumentor 1.4.3