Class mail_fetch

Description

POP3 client class

POP connection is opened when class is constructed. All command_* methods execute specific POP commands on server. Most of other methods should be used only internally. Only login() method is public. If command returns mixed content and you expect message text, ids or something else, make sure that it is not boolean false.

Basic use:

  1. create object with connection params, see mail_fetch method.
  2. check error buffer
  3. login($username,$password) - true = login successful, false = login error.
  4. command_stat() - get number of messages
  5. command_list() - get message ids, use command_uidl(), if you implement
'keep mess on server' functions. Make sure that you handle possible UIDL command errors. 6. command_retr($some_message_id) - get message contents 7. command_dele($some_message_id) - mark message for deletion 8. command_quit() - close connection. You must close connection in order to delete messages and remove mailbox lock.

Located in /plugins/mail_fetch/class.mail_fetch.php (line 43)


	
			
Variable Summary
integer $auth
stream $conn
string $error
string $greeting
string $host
integer $port
string $response
integer $timeout
string $timestamp
integer $tls
Method Summary
mail_fetch mail_fetch ([array $aParams = array()])
void check_php_version ([ $a = '0'], [ $b = '0'], [ $c = '0'])
boolean check_response ()
boolean command_apop (string $username, string $password)
void command_capa ()
boolean command_dele (integer $msg)
mixed command_list ([integer $msg = ''])
boolean command_noop ()
boolean command_pass (string $password)
void command_quit ()
mixed command_retr (integer $msg)
boolean command_rset ()
mixed command_stat ()
boolean command_stls ()
string command_top (integer $msg, integer $n)
mixed command_uidl ([integer $msg = ''])
boolean command_user (string $username)
boolean login (string $username, string $password)
boolean open ()
boolean set_error (string $error, [boolean $close_conn = false])
Variables
integer $auth = 1 (line 77)

Authentication type

Bitwise variable. If variable covers more than one authentication method, login() tries to use all of them until first successful auth.

  1. - user/pass (rfc1939, default)
  2. - apop (rfc1939, timestamp must be present in greeting)
  3. - apop or user/pass

array $capabilities = array() (line 107)

Capabilities (POP3EXT capa)

stream $conn = false (line 89)

Connection resource

string $error = '' (line 113)

Error message buffer

string $greeting = '' (line 95)

Server greeting

string $host = '' (line 48)

Server name

integer $port = 0 (line 55)

POP connection port.

Defaults to 110 on plain text connections and to 995 on TLS

string $response = '' (line 123)

Response buffer

Variable is used to store last positive POP server response checked in check_response() method. Used internally to handle mixed single and multiline command responses.

integer $timeout = 60 (line 83)

Connection timeout

string $timestamp = '' (line 101)

Timestamp (with <> or empty string)

integer $tls = 0 (line 65)

Connection type

  1. - plain text (default)
  2. - tls (php 4.3 and openssl extension requirement)
  3. - stls (stream_socket_enable_crypto() requirement. PHP 5.1.0, POP3 server with POP3EXT and STLS support)

Methods
Constructor mail_fetch (line 137)

Constructor function

parameter array keys 'host' - required string, address of server. ip or fqn 'port' - optional integer, port of server. 'tls' - optional integer, connection type 'timeout' - optional integer, connection timeout 'auth' - optional integer, used authentication mechanism. See description of class properties

mail_fetch mail_fetch ([array $aParams = array()])
  • array $aParams: connection params
check_php_version (line 254)

Standard SquirrelMail function copied to class in order to make class independent from SquirrelMail.

void check_php_version ([ $a = '0'], [ $b = '0'], [ $c = '0'])
  • $a
  • $b
  • $c
check_response (line 237)

Reads first response line and checks it for errors

  • return: true = success, false = failure, check error buffer
boolean check_response ()
command_apop (line 517)

APOP authentication

Command is optional and not required by rfc1939. APOP support requires plain text passwords stored on server and some servers don't support it. Standard qmail pop3d declares apop support without checking if checkpassword supports it.

  • return: true = success, false = failure.
boolean command_apop (string $username, string $password)
  • string $username
  • string $password
command_capa (line 535)

Checks pop server capabilities

RFC2449. Fills capabilities array.

void command_capa ()
command_dele (line 386)
boolean command_dele (integer $msg)
  • integer $msg
command_list (line 330)

List mailbox messages

  • return: array with message ids (keys) and sizes (values) or boolean false
mixed command_list ([integer $msg = ''])
  • integer $msg
command_noop (line 395)

POP noop command

boolean command_noop ()
command_pass (line 501)

USER authentication (password command)

Command is optional and not required by rfc1939. Requires successful user command.

  • return: true = success, false = failure.
boolean command_pass (string $password)
  • string $password
command_quit (line 412)

Closes POP connection

void command_quit ()
command_retr (line 362)

Gets message text

  • return: rfc822 message (CRLF line endings) or boolean false
mixed command_retr (integer $msg)
  • integer $msg: message id
command_rset (line 404)

Resets message state

boolean command_rset ()
command_stat (line 314)

Gets mailbox status

array with 'count' and 'size' keys

  • return: array or boolean false
mixed command_stat ()
command_stls (line 561)

RFC 2595 POP STARTTLS support

boolean command_stls ()
command_top (line 428)

Gets message headers and $n of body lines.

Command is optional and not required by rfc1939

  • return: or boolean false
string command_top (integer $msg, integer $n)
  • integer $msg
  • integer $n
command_uidl (line 453)

Gets unique message ids

Command is optional and not required by rfc1939

  • return: array with message ids (keys) and unique ids (values) or boolean false
mixed command_uidl ([integer $msg = ''])
  • integer $msg: message id
command_user (line 488)

USER authentication (username command)

Command is optional and not required by rfc1939. If command is successful, pass command must be executed after it.

  • return: true = success, false = failure.
boolean command_user (string $username)
  • string $username
login (line 267)

Generic login wrapper

Connection is not closed on login error (unless POP server drops connection)

boolean login (string $username, string $password)
  • string $username
  • string $password
open (line 184)

Opens pop connection

Command handles TLS and STLS connection differences and fills capabilities array with RFC2449 CAPA data.

boolean open ()
set_error (line 299)

Sets error in error buffer and returns boolean false

  • return: false
boolean set_error (string $error, [boolean $close_conn = false])
  • string $error: Error message
  • boolean $close_conn: Do we have to close connection

Documentation generated on Mon, 13 Jan 2020 04:22:03 +0100 by phpDocumentor 1.4.3