File/nasmail/functions/imap_general.php

Description

imap_general.php

This implements all functions that do general IMAP functions.

  • version: $Id: imap_general.php 1446 2009-10-08 18:40:02Z tokul $
  • copyright: (c) 1999-2006 The SquirrelMail Project Team
  • copyright: (c) 2006-2007,2009 The NaSMail Project
  • license: GNU Public License
Includes
 require_once (SM_PATH.'functions/page_header.php') (line 17)

Includes..

 require_once (SM_PATH.'functions/auth.php') (line 18)
Functions
map_yp_alias (line 1367)

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.

  • return: name or address of IMAP server
string map_yp_alias (string $username)
  • string $username: user name.
nsm_imap_check_cont_request (line 1334)

Checks IMAP continuation responses in commands with literal strings

  • return: true - continue sending command, false - server returned error.
  • since: 1.7
boolean nsm_imap_check_cont_request (stream $imap_stream, string $session_id, string &$errmsg)
  • stream $imap_stream: IMAP connection
  • string $session_id: Session ID of command
  • string &$errmsg: Last IMAP server's response
nsm_imap_login (line 587)

Logs the user into the IMAP server. If $hide is set, no error messages will be displayed. This function returns the IMAP connection handle.

Function replaces sqimap_login(). $password argument must contain decoded password information.

  • return: IMAP connection resource
  • since: 1.2
stream nsm_imap_login (string $username, string $password, string $imap_server_address, integer $imap_port, boolean $hide)
  • string $username: username
  • string $password: plain text password
  • string $imap_server_address: address of IMAP server or mapping ('map:function_name')
  • integer $imap_port: port of IMAP server
  • boolean $hide: hide connection errors
nsm_imap_quote_string (line 1315)

Quotes strings in IMAP commands

  • since: 1.7
string nsm_imap_quote_string (string $str)
  • string $str
parseAddress (line 1002)
void parseAddress ($address $address, [$max $max = 0])
  • $address $address
  • $max $max
sqimap_append (line 1233)

Saves a message to a given folder -- used for saving sent messages Function executes APPEND command without message literal. IMAP server will wait for message literal after function is executed.

  • return: errors are handled internally with sqimap_append_checkresponse() function
void sqimap_append (stream $imap_stream, string $sent_folder, integer $length)
  • stream $imap_stream: IMAP connection resource
  • string $sent_folder: mailbox name (utf7-imap encoded)
  • integer $length: message size
sqimap_append_checkresponse (line 1258)

Checks APPEND responses Is used to process response to APPEND command and response to submitted message literal.

  • return: stops with fatal execution error on BAD response or prints error box on NO response.
void sqimap_append_checkresponse (string $response, string $folder)
  • string $response: response of IMAP server
  • string $folder: folder used in APPEND command.
sqimap_append_done (line 1245)

Ends APPEND command and checks response of IMAP server.

  • return: errors are handled internally with sqimap_append_checkresponse() function
void sqimap_append_done (stream $imap_stream, [string $folder = ''])
  • stream $imap_stream: IMAP connection resource
  • string $folder
sqimap_capability (line 894)

Retrieves CAPABILITY information from IMAP server

If second argument is set, function returns boolean indicating support of specified feature. If argument is not set, function returns whole capabilities array.

Function was modified in 1.5. Before that $capability='name=value' tests were unsupported and $capability='name' tests could return boolean or string.

Information is cached in session 'sqimap_capabilities' variable. Please note that on some servers CAPABILITY response depends on connection state. For example, plain text connections might hide AUTH=LOGIN or AUTH=PLAIN before encryption is turned on with STARTTLS or list of capabilities won't include supported authentication methods after successful authentication. Use cached information only when you need information that does not depend on authentication and connection encryption state.

  • return: array with capability entries, if second argument is not set, boolean, if it is set
array|boolean sqimap_capability (stream $imap_stream, [string $capability = ''], [boolean $use_cache = true])
  • stream $imap_stream: IMAP connection resource
  • string $capability: check for one specific capability
  • boolean $use_cache: (since 1.5) Controls use of cached capability information
sqimap_fgets (line 187)

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

  • return: a line
string sqimap_fgets (stream $imap_stream)
  • stream $imap_stream: imap_stream the stream to read from
sqimap_fread (line 216)
string sqimap_fread (stream $imap_stream, integer $iSize, [string $filter = false], [mixed $outputstream = false], [boolean $no_return = false])
  • stream $imap_stream: IMAP connection resource
  • integer $iSize
  • string $filter: function used to process output
  • mixed $outputstream: resource or 'php://stdout'. Write output to specified resource handle or to stdout.
  • boolean $no_return
sqimap_get_delimiter (line 937)

Returns the delimiter between mailboxes: INBOX/Test, or INBOX.Test If $optional_delimiter configuration variable is not set to 'detect', function returns $optional_delimiter value.

Function uses delimiter from personal namespace (rfc2342) or INBOX.

string sqimap_get_delimiter ([stream $imap_stream = false])
  • stream $imap_stream: IMAP connection resource
sqimap_get_num_messages (line 988)

Gets the number of messages in the current mailbox.

  • return: number from EXISTS response or false
mixed sqimap_get_num_messages (stream $imap_stream, string $mailbox)
  • stream $imap_stream: IMAP connection resource
  • string $mailbox: mailbox name (utf7-imap encoded)
sqimap_get_user_server (line 1300)

Function handles imap server mappings

If imap_server is set to 'map:some_function', code executes that function with username argument and returns result.

  • return: name or address of IMAP server
string sqimap_get_user_server (string $imap_server, string $username)
  • string $imap_server
  • string $username
sqimap_login (line 569)

Logs the user into the IMAP server. If $hide is set, no error messages will be displayed. This function returns the IMAP connection handle.

Old style function. $password is encrypted with one time pad. Since NaSMail 1.2 function ignores submitted password information and gets it with standard NaSMail functions.

  • return: IMAP connection resource
  • deprecated: 1.2 - 2007.06.14 Use nsm_imap_login instead.
stream sqimap_login (string $username, string $password, string $imap_server_address, integer $imap_port, boolean $hide)
  • string $username: username
  • string $password: password encrypted with one time pad.
  • string $imap_server_address: address of IMAP server or mapping ('map:function_name')
  • integer $imap_port: port of IMAP server
  • boolean $hide: hide connection errors
sqimap_logout (line 863)

Simply logs out the IMAP session

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

Read single line IMAP response

string sqimap_read_data (stream $imap_stream, mixed $tag_uid, boolean $handle_errors, mixed &$response, mixed &$message, [string $query = ''], [mixed $filter = false], [resource $outputstream = false], [boolean $no_return = false])
  • stream $imap_stream
  • mixed $tag_uid
  • boolean $handle_errors
  • mixed &$response
  • mixed &$message
  • string $query
  • mixed $filter
  • resource $outputstream
  • boolean $no_return
sqimap_read_data_list (line 285)

Reads the output from the IMAP stream.

array sqimap_read_data_list (stream $imap_stream, mixed $tag_uid, boolean $handle_errors, mixed &$response, mixed &$message, [string $query = ''], [string $filter = false], [mixed $outputstream = false], [boolean $no_return = false])
  • stream $imap_stream
  • mixed $tag_uid
  • boolean $handle_errors: 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.
  • mixed &$response
  • mixed &$message
  • string $query
  • string $filter
  • mixed $outputstream
  • boolean $no_return
sqimap_run_command (line 115)

Execute IMAP command, when one line response is expected

Warning. If response contains more than one line, other lines are ignored.

  • return: false on error, string with first sqimap_read_data_list array entry on success.
mixed sqimap_run_command (stream $imap_stream, string $query, boolean $handle_errors, mixed &$response, mixed &$message, [boolean $unique_id = false], [boolean $filter = false], [mixed $outputstream = false], [mixed $no_return = false])
  • stream $imap_stream: imap_stream IMAP connection resource
  • string $query: query IMAP command (without trailing CRLF)
  • boolean $handle_errors: handle_errors error handling
  • mixed &$response: response
  • mixed &$message: message
  • boolean $unique_id: unique_id controls use of UID command prefix in executed queries
  • boolean $filter: filter
  • mixed $outputstream: outputstream
  • mixed $no_return: no_return
sqimap_run_command_list (line 46)

Execute IMAP command, when multiline response is expected

  • return: false on error, sqimap_read_data_list() array on successful execution
mixed sqimap_run_command_list (stream $imap_stream, string $query, boolean $handle_errors, mixed &$response, mixed &$message, [boolean $unique_id = false])
  • stream $imap_stream: imap_stream IMAP connection resource
  • string $query: query IMAP command (without trailing CRLF)
  • boolean $handle_errors: handle_errors
  • mixed &$response: response
  • mixed &$message: message
  • boolean $unique_id: unique_id controls use of UID command prefix in executed queries
sqimap_session_id (line 26)

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'.
string sqimap_session_id ([bool $unique_id = FALSE])
  • bool $unique_id: unique_id controls use of IMAP UID command
sqimap_status_messages (line 1203)

Returns the number of unseen/total messages in this folder

  • return: array with MESSAGES, UNSEEN and RECENT keys with message stats for selected mailbox
array sqimap_status_messages (stream $imap_stream, string $mailbox)
  • stream $imap_stream: IMAP connection resource
  • string $mailbox: mailbox name (utf7-imap encoded)
sqimap_unseen_messages (line 1184)

Returns the number of unseen messages in this folder.

  • return: number of unseen messages in mailbox
integer sqimap_unseen_messages (stream $imap_stream, string $mailbox)
  • stream $imap_stream: IMAP connection resource
  • string $mailbox: mailbox name (utf7-imap encoded)

Documentation generated on Sun, 22 Nov 2009 17:36:38 +0200 by phpDocumentor 1.4.3