Smart.Framework Logo

final class \SmartMailerImap4Client
{ } ->

Class: SmartMailerImap4Client - provides an IMAP4 Mail Client with SSL/TLS support.


class Methods

public function __construct ( $buffer = 0 ) {} @ 
IMAP4 Client Class constructor
public function is_connected_and_logged_in ( ) {} -> 
Get The Connected + Logged In Status
public function get_selected_mailbox ( ) {} -> 
Get The Selected MailBox (on IMAP4 will be available just after connect + login + select mailbox)
public function clear_last_error ( ) {} -> 
Clear the Last Error
public function set_ssl_tls_ca_file ( STRING $cafile ) {} -> VOID
@return: {VOID}
@param: {STRING} $cafile: Relative Path to a SSL Certificate Authority File (Ex: store within smart-framework/etc/certificates ; specify as 'etc/certificates/ca.pem') ; IMPORTANT: in this case the 'etc/certificates/' directory must be protected with a .htaccess to avoid being public readable - the directory and any files within this directory ...)
Set a SSL/TLS Certificate Authority File
If not set but SMART_FRAMEWORK_SSL_CA_FILE is defined will use the SMART_FRAMEWORK_SSL_CA_FILE
public function connect ( STRING $server, INTEGER+ $port = 143, ENUM $sslversion = "" ) {} -> INTEGER+
@return: {INTEGER+} 1 on success, 0 on fail
@param: {STRING} $server: The Server Hostname or IP address
@param: {INTEGER+} $port: *Optional* The Server Port ; Default is: 143
@param: {ENUM} $sslversion: To connect using SSL mode this must be set to any of these accepted values: '', 'starttls', 'starttls:1.0', 'starttls:1.1', 'starttls:1.2', 'tls', 'tls:1.0', 'tls:1.1', 'tls:1.2', 'ssl', 'sslv3' ; If empty string is set here it will be operate in unsecure mode (NOT using any SSL/TLS Mode)
Will try to open a socket to the specified IMAP4 Server using the host/ip and port ; If a SSL option is selected will try to establish a SSL socket or fail
public function noop ( ) {} -> INTEGER+
@return: {INTEGER+} 1 on Success or 0 on Error
Ping the IMAP4 Server
Sends the command NOOP to the Server
public function reset ( ) {} -> INTEGER+
@return: {INTEGER+} 1 on Success or 0 on Error
Reset the IMAP4 server connection (includding all messages marked to be deleted)
public function quit ( $expunge = false ) {} -> INTEGER+
@return: {INTEGER+} 1 on Success or 0 on Error
Sends the CLOSE/UNSELECT/LOGOUT commands set to the IMAP4 server
Closes the communication socket after sending LOGOUT command
public function login ( STRING $username, STRING $pass, ENUM $mode = "" ) {} -> INTEGER+
@return: {INTEGER+} 1 on Success or 0 on Failure or Error
@param: {STRING} $username: The authentication username
@param: {STRING} $pass: The authentication password
@param: {ENUM} $mode: *Optional* The authentication mode ; can be set to any of: 'login', 'auth:plain', 'auth:cram-md5', 'auth:xoauth2' ; Default is 'auth:plain'
Try to Login/Authenticate on the IMAP4 Server with a username and password (or token for auth:xoauth2)
Sends both user and pass to the Server
public function select_mailbox ( STRING $mbox_name, BOOLEAN $allow_create = false ) {} -> INTEGER+
@return: {INTEGER+} 1 on Success or 0 on Failure or Error
@param: {STRING} $mbox_name: The MailBox to Select ; Ex: 'Inbox' or 'Sent' or 'Trash' or 'Spam' or ... 'Sent Items', ...
@param: {BOOLEAN} $allow_create: If MailBox does not exists and this param is set to TRUE then MailBox will be created
Selects a MailBox after login on the IMAP4 Server
Unlike the POP3 servers the IMAP4 servers can operate on multiple MailBoxes over the same account
public function get_metadata ( ) {} -> ARRAY
@return: {ARRAY} Which contains the following keys [ 'uivalidity' => 'CurrentUIV', 'count' => 101, 'recent' => '', 'size' => 1024 ]
Get all the IMAP4 MetaData for the selected account MailBox
public function count ( ) {} -> ARRAY
@return: {ARRAY} Which contains the following keys [ 'size' => 1024, 'count' => 101, 'recent' => '' ]
Get The Count Information for the selected account MailBox
public function uid ( STRING $msg_num = "" ) {} -> STRING
@return: {STRING} A unique UID or a list with multiple (ar all) UIDs ; returns empty string on error
@param: {STRING} $msg_num: *Optional* A specific UID for a specific message or leave empty to get the list with all UIDs
Get the list of UIDs or a specific UID for the selected message
The UID(s) will be formated as this library does: 'IMAP4-UIV-@num@-UID-@uid@'
A list with multiple UIDs provided by this method can be parsed using $imap4->parse_uidls($list)
public function parse_uidls ( STRING $y_list ) {} -> ASSOCIATIVE
@hints: Some IMAP4 servers have non-standard responses for the format of $mailget->uid() and in this case you may have to build your own parser ...
@return: {ASSOCIATIVE} ARRAY the list of parsed UIDs as [ id1 => uid1, id2 => uid2, ..., idN => uidN ]
@param: {STRING} $y_list: The UIDs list given by the IMAP4 server with command: $mailget->uid() ; Expects a format similar with: ID[SPACE]UID\n
Parse the (standard) list of UIDs supplied IMAP4 protocol
The UIDs will be formated as this library does: 'IMAP4-UIV-@num@-UID-@uid@'
public function size ( STRING $msg_num, BOOLEAN $by_uid = false ) {} -> STRING
@hints: Some servers may not comply with this method and may return empty result
@return: {STRING} the size of the selected message (ussualy in Bytes) or empty string if Error
@param: {STRING} $msg_num: The Message Number
@param: {BOOLEAN} $by_uid: *Optional* ; Default is FALSE ; If TRUE a Message UID should be supplied for 1st param ; If FALSE a Message Number should be supplied for 1st param
Get the size for the selected message
public function delete ( STRING $msg_num, BOOLEAN $by_uid = false ) {} -> INTEGER+
@return: {INTEGER+} 1 on Success or 0 on Failure or Error
@param: {STRING} $msg_num: The Message Number or Message UID if 2nd param is set to TRUE
@param: {BOOLEAN} $by_uid: *Optional* ; Default is FALSE ; If TRUE a Message UID should be supplied for 1st param ; If FALSE a Message Number should be supplied for 1st param
Delete a message stored on the IMAP4 Server
public function header ( STRING $msg_num, BOOLEAN $by_uid = false, INTEGER+ $read_lines = 5 ) {} -> STRING
@return: {STRING} The first lines of the message body or empty string on ERROR
@param: {STRING} $msg_num: The Message Number
@param: {BOOLEAN} $by_uid: *Optional* ; Default is FALSE ; If TRUE a Message UID should be supplied for 1st param ; If FALSE a Message Number should be supplied for 1st param
@param: {INTEGER+} $read_lines: The number of lines to retrieve 1..255
Get the Message Head Lines (first lines of the message body)
public function read ( STRING $msg_num, BOOLEAN $by_uid = false ) {} -> STRING
@return: {STRING} The full message containing the Message Headers and Body as stored on the server or empty string on ERROR
@param: {STRING} $msg_num: The Message Number or Message UID if 2nd param is set to TRUE
@param: {BOOLEAN} $by_uid: *Optional* ; Default is FALSE ; If TRUE a Message UID should be supplied for 1st param ; If FALSE a Message Number should be supplied for 1st param
Get the Entire Message from Server
public function copy ( $msg_uid, STRING $dest_mbox, BOOLEAN $by_uid = false ) {} -> INTEGER+
@return: {INTEGER+} 1 on Success or 0 on Failure or Error
@param: {STRING} $msg_num: The Message Number or Message UID if 3rd param is set to TRUE
@param: {STRING} $dest_mbox: The destination MailBox name ; Ex: 'Trash' or 'Deleted Messages' or 'Archive', ...
@param: {BOOLEAN} $by_uid: *Optional* ; Default is FALSE ; If TRUE a Message UID should be supplied for 1st param ; If FALSE a Message Number should be supplied for 1st param
COPY a Message from the current selected MailBox to another (destination) MailBox
public function append ( STRING $message ) {} -> STRING
@return: {STRING} The UID of the new uploaded message or Empty string on Error
@param: {STRING} $message: The full message containing the headers and the body as stored locally
STORE an uploaded Message to the current selected MailBox

class Properties

public $buffer = 2048 ;  -> INT
socket read buffer
public $timeout = 30 ;  -> INT
socket timeout in seconds
public $debug = FALSE ;  -> BOOLEAN
debug on/off
public $error = '' ;  -> STRING
This should be checked after each operation on the server
The error message(s) will be collected here
do not SET a value here, but just GET the result
public $log = '' ;  -> STRING
The operations log (only if debug is enabled)
Do not SET a value here, but just GET the result

class Constants



documentation generated on: 2023-10-19 23:15:46 +0000


Smart.Framework © 2009-2023 unix-world.org