Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes

Zend_Mail_Protocol_Imap Class Reference

Public Member Functions

 __construct ($host= '', $port=null, $ssl=false)
 __destruct ()
 connect ($host, $port=null, $ssl=false)
 readLine (&$tokens=array(), $wantedTag= '*', $dontParse=false)
 readResponse ($tag, $dontParse=false)
 sendRequest ($command, $tokens=array(), &$tag=null)
 requestAndResponse ($command, $tokens=array(), $dontParse=false)
 escapeString ($string)
 escapeList ($list)
 login ($user, $password)
 logout ()
 capability ()
 examineOrSelect ($command= 'EXAMINE', $box= 'INBOX')
 select ($box= 'INBOX')
 examine ($box= 'INBOX')
 fetch ($items, $from, $to=null)
 listMailbox ($reference= '', $mailbox= '*')
 store (array $flags, $from, $to=null, $mode=null, $silent=true)
 append ($folder, $message, $flags=null, $date=null)
 copy ($folder, $from, $to=null)
 create ($folder)
 rename ($old, $new)
 delete ($folder)
 expunge ()
 noop ()
 search (array $params)

Data Fields

const TIMEOUT_CONNECTION = 30

Protected Member Functions

 _nextLine ()
 _assumedNextLine ($start)
 _nextTaggedLine (&$tag)
 _decodeLine ($line)

Protected Attributes

 $_socket
 $_tagCount = 0

Detailed Description

Definition at line 31 of file Imap.php.


Constructor & Destructor Documentation

__construct ( host = '',
port = null,
ssl = false 
)

Public constructor

Parameters:
string$hosthostname or IP address of IMAP server, if given connect() is called
int | null$portport of IMAP server, null for default (143 or 993 for ssl)
bool$ssluse ssl? 'SSL', 'TLS' or false
Exceptions:
Zend_Mail_Protocol_Exception

Definition at line 58 of file Imap.php.

__destruct (  )

Public destructor

Definition at line 68 of file Imap.php.


Member Function Documentation

_assumedNextLine ( start ) [protected]

get next line and assume it starts with $start. some requests give a simple feedback so we can quickly check if we can go on.

Parameters:
string$startthe first bytes we assume to be in the next line
Returns:
bool line starts with $start
Exceptions:
Zend_Mail_Protocol_Exception

Definition at line 153 of file Imap.php.

_decodeLine ( line ) [protected]

split a given line in tokens. a token is literal of any form or a list

Parameters:
string$lineline to decode
Returns:
array tokens, literals are returned as string, lists as array
Exceptions:
Zend_Mail_Protocol_Exception

Definition at line 183 of file Imap.php.

_nextLine (  ) [protected]

get the next line from socket with error checking, but nothing else

Returns:
string next line
Exceptions:
Zend_Mail_Protocol_Exception

See also:
Zend_Mail_Protocol_Exception

Definition at line 131 of file Imap.php.

_nextTaggedLine ( &$  tag ) [protected]

get next line and split the tag. that's the normal case for a response line

Parameters:
string$tagtag of line is returned by reference
Returns:
string next line
Exceptions:
Zend_Mail_Protocol_Exception

Definition at line 166 of file Imap.php.

append ( folder,
message,
flags = null,
date = null 
)

append a new message to given folder

Parameters:
string$foldername of target folder
string$messagefull message content
array$flagsflags for new message
string$datedate for new message
Returns:
bool success
Exceptions:
Zend_Mail_Protocol_Exception

Definition at line 723 of file Imap.php.

capability (  )

Get capabilities from IMAP server

Returns:
array list of capabilities
Exceptions:
Zend_Mail_Protocol_Exception

Definition at line 476 of file Imap.php.

connect ( host,
port = null,
ssl = false 
)

Open connection to IMAP server

Parameters:
string$hosthostname or IP address of IMAP server
int | null$portof IMAP server, default is 143 (993 for ssl)
string | bool$ssluse 'SSL', 'TLS' or false
Returns:
string welcome message
Exceptions:
Zend_Mail_Protocol_Exception

See also:
Zend_Mail_Protocol_Exception
Zend_Mail_Protocol_Exception
Zend_Mail_Protocol_Exception

Definition at line 82 of file Imap.php.

copy ( folder,
from,
to = null 
)

copy message set from current folder to other folder

Parameters:
string$folderdestination folder
int | null$toif null only one message ($from) is fetched, else it's the last message, INF means last message avaible
Returns:
bool success
Exceptions:
Zend_Mail_Protocol_Exception

Definition at line 747 of file Imap.php.

create ( folder )

create a new folder (and parent folders if needed)

Parameters:
string$folderfolder name
Returns:
bool success

Definition at line 763 of file Imap.php.

delete ( folder )

remove a folder

Parameters:
string$folderfolder name
Returns:
bool success

Definition at line 786 of file Imap.php.

escapeList ( list )

escape a list with literals or lists

Parameters:
array$listlist with literals or lists as PHP array
Returns:
string escaped list for imap

Definition at line 422 of file Imap.php.

escapeString ( string )

escape one or more literals i.e. for sendRequest

Parameters:
string | array$stringthe literal/-s
Returns:
string|array escape literals, literals with newline ar returned as array('{size}', 'string');

Definition at line 400 of file Imap.php.

examine ( box = 'INBOX' )

examine folder

Parameters:
string$boxexamine this folder
Returns:
bool|array see examineOrselect()
Exceptions:
Zend_Mail_Protocol_Exception

Definition at line 550 of file Imap.php.

examineOrSelect ( command = 'EXAMINE',
box = 'INBOX' 
)

Examine and select have the same response. The common code for both is in this method

Parameters:
string$commandcan be 'EXAMINE' or 'SELECT' and this is used as command
string$boxwhich folder to change to or examine
Returns:
bool|array false if error, array with returned information otherwise (flags, exists, recent, uidvalidity)
Exceptions:
Zend_Mail_Protocol_Exception

Definition at line 501 of file Imap.php.

expunge (  )

permanently remove messages

Returns:
bool success

Definition at line 796 of file Imap.php.

fetch ( items,
from,
to = null 
)

fetch one or more items of one or more messages

Parameters:
string | array$itemsitems to fetch from message(s) as string (if only one item) or array of strings
int$frommessage for items or start message if $to !== null
int | null$toif null only one message ($from) is fetched, else it's the last message, INF means last message avaible
Returns:
string|array if only one item of one message is fetched it's returned as string if items of one message are fetched it's returned as (name => value) if one items of messages are fetched it's returned as (msgno => value) if items of messages are fetchted it's returned as (msgno => (name => value))
Exceptions:
Zend_Mail_Protocol_Exception

See also:
Zend_Mail_Protocol_Exception

Definition at line 569 of file Imap.php.

listMailbox ( reference = '',
mailbox = '*' 
)

get mailbox list

this method can't be named after the IMAP command 'LIST', as list is a reserved keyword

Parameters:
string$referencemailbox reference for list
string$mailboxmailbox name match with wildcards
Returns:
array mailboxes that matched $mailbox as array(globalName => array('delim' => .., 'flags' => ..))
Exceptions:
Zend_Mail_Protocol_Exception

Definition at line 649 of file Imap.php.

login ( user,
password 
)

Login to IMAP server.

Parameters:
string$userusername
string$passwordpassword
Returns:
bool success
Exceptions:
Zend_Mail_Protocol_Exception

Definition at line 444 of file Imap.php.

logout (  )

logout of imap server

Returns:
bool success

Definition at line 454 of file Imap.php.

noop (  )

send noop

Returns:
bool success

Definition at line 807 of file Imap.php.

readLine ( &$  tokens = array(),
wantedTag = '*',
dontParse = false 
)

read a response "line" (could also be more than one real line if response has {..}<NL>) and do a simple decode

Parameters:
array | string$tokensdecoded tokens are returned by reference, if $dontParse is true the unparsed line is returned here
string$wantedTagcheck for this tag for response code. Default '*' is continuation tag.
bool$dontParseif true only the unparsed line is returned $tokens
Returns:
bool if returned tag matches wanted tag
Exceptions:
Zend_Mail_Protocol_Exception

Definition at line 283 of file Imap.php.

readResponse ( tag,
dontParse = false 
)

read all lines of response until given tag is found (last line of response)

Parameters:
string$tagthe tag of your request
string | array$filteryou can filter the response so you get only the given response lines
bool$dontParseif true every line is returned unparsed instead of the decoded tokens
Returns:
null|bool|array tokens if success, false if error, null if bad request
Exceptions:
Zend_Mail_Protocol_Exception

Definition at line 307 of file Imap.php.

rename ( old,
new 
)

rename an existing folder

Parameters:
string$oldold name
string$newnew name
Returns:
bool success

Definition at line 775 of file Imap.php.

requestAndResponse ( command,
tokens = array(),
dontParse = false 
)

send a request and get response at once

Parameters:
string$commandcommand as in sendRequest()
array$tokensparameters as in sendRequest()
bool$dontParseif true unparsed lines are returned instead of tokens
Returns:
mixed response as in readResponse()
Exceptions:
Zend_Mail_Protocol_Exception

Definition at line 385 of file Imap.php.

search ( array $  params )

do a search request

This method is currently marked as internal as the API might change and is not safe if you don't take precautions.

Definition at line 822 of file Imap.php.

select ( box = 'INBOX' )

change folder

Parameters:
string$boxchange to this folder
Returns:
bool|array see examineOrselect()
Exceptions:
Zend_Mail_Protocol_Exception

Definition at line 538 of file Imap.php.

sendRequest ( command,
tokens = array(),
&$  tag = null 
)

send a request

Parameters:
string$commandyour request command
array$tokensadditional parameters to command, use escapeString() to prepare
string$tagprovide a tag otherwise an autogenerated is returned
Returns:
null
Exceptions:
Zend_Mail_Protocol_Exception

See also:
Zend_Mail_Protocol_Exception
Zend_Mail_Protocol_Exception
Zend_Mail_Protocol_Exception

Definition at line 336 of file Imap.php.

store ( array $  flags,
from,
to = null,
mode = null,
silent = true 
)

set flags

Parameters:
array$flagsflags to set, add or remove - see $mode
int$frommessage for items or start message if $to !== null
int | null$toif null only one message ($from) is fetched, else it's the last message, INF means last message avaible
string | null$mode'+' to add flags, '-' to remove flags, everything else sets the flags as given
bool$silentif false the return values are the new flags for the wanted messages
Returns:
bool|array new flags if $silent is false, else true or false depending on success
Exceptions:
Zend_Mail_Protocol_Exception

Definition at line 679 of file Imap.php.


Field Documentation

const TIMEOUT_CONNECTION = 30

Default timeout in seconds for initiating session

Definition at line 36 of file Imap.php.


The documentation for this class was generated from the following file: