category Zend
package Zend_Mail
subpackage Protocol
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License

 Methods

Public constructor

__construct(string $host = '', integer|null $port = null, boolean $ssl = false

Parameters

$host

string

hostname or IP address of IMAP server, if given connect() is called

$port

integernull

port of IMAP server, null for default (143 or 993 for ssl)

$ssl

boolean

use ssl? 'SSL', 'TLS' or false

Exceptions

\Zend_Mail_Protocol_Exception

Public destructor

__destruct() 

append a new message to given folder

append(string $folder, string $message, array $flags = null, string $date = null) : boolean

Parameters

$folder

string

name of target folder

$message

string

full message content

$flags

array

flags for new message

$date

string

date for new message

Exceptions

\Zend_Mail_Protocol_Exception

Returns

booleansuccess

Get capabilities from IMAP server

capability() : array

Exceptions

\Zend_Mail_Protocol_Exception

Returns

arraylist of capabilities

Open connection to IMAP server

connect(string $host, integer|null $port = null, string|boolean $ssl = false) : string

Parameters

$host

string

hostname or IP address of IMAP server

$port

integernull

of IMAP server, default is 143 (993 for ssl)

$ssl

stringboolean

use 'SSL', 'TLS' or false

Exceptions

\Zend_Mail_Protocol_Exception

Returns

stringwelcome message

copy message set from current folder to other folder

copy(string $folder, $from, integer|null $to = null) : boolean

Parameters

$folder

string

destination folder

$from

$to

integernull

if null only one message ($from) is fetched, else it's the last message, INF means last message avaible

Exceptions

\Zend_Mail_Protocol_Exception

Returns

booleansuccess

create a new folder (and parent folders if needed)

create(string $folder) : boolean

Parameters

$folder

string

folder name

Returns

booleansuccess

remove a folder

delete(string $folder) : boolean

Parameters

$folder

string

folder name

Returns

booleansuccess

escape a list with literals or lists

escapeList(array $list) : string

Parameters

$list

array

list with literals or lists as PHP array

Returns

stringescaped list for imap

escape one or more literals i.e. for sendRequest

escapeString(string|array $string) : string | array

Parameters

$string

stringarray

the literal/-s

Returns

stringarrayescape literals, literals with newline ar returned as array('{size}', 'string');

examine folder

examine(string $box = 'INBOX') : boolean | array

Parameters

$box

string

examine this folder

Exceptions

\Zend_Mail_Protocol_Exception

Returns

booleanarraysee examineOrselect()

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

examineOrSelect(string $command = 'EXAMINE', string $box = 'INBOX') : boolean | array

Parameters

$command

string

can be 'EXAMINE' or 'SELECT' and this is used as command

$box

string

which folder to change to or examine

Exceptions

\Zend_Mail_Protocol_Exception

Returns

booleanarrayfalse if error, array with returned information otherwise (flags, exists, recent, uidvalidity)

permanently remove messages

expunge() : boolean

Returns

booleansuccess

fetch one or more items of one or more messages

fetch(string|array $items, integer $from, integer|null $to = null) : string | array

Parameters

$items

stringarray

items to fetch from message(s) as string (if only one item) or array of strings

$from

integer

message for items or start message if $to !== null

$to

integernull

if null only one message ($from) is fetched, else it's the last message, INF means last message avaible

Exceptions

\Zend_Mail_Protocol_Exception

Returns

stringarrayif 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))

get mailbox list

listMailbox(string $reference = '', string $mailbox = '*') : array

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

Parameters

$reference

string

mailbox reference for list

$mailbox

string

mailbox name match with wildcards

Exceptions

\Zend_Mail_Protocol_Exception

Returns

arraymailboxes that matched $mailbox as array(globalName => array('delim' => .., 'flags' => ..))

logout of imap server

logout() : boolean

Returns

booleansuccess

send noop

noop() : boolean

Returns

booleansuccess

read a response "line" (could also be more than one real line if response has {.

readLine(array|string $tokens = array(), string $wantedTag = '*', boolean $dontParse = false) : boolean

.}) and do a simple decode

Parameters

$tokens

arraystring

decoded tokens are returned by reference, if $dontParse is true the unparsed line is returned here

$wantedTag

string

check for this tag for response code. Default '*' is continuation tag.

$dontParse

boolean

if true only the unparsed line is returned $tokens

Exceptions

\Zend_Mail_Protocol_Exception

Returns

booleanif returned tag matches wanted tag

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

readResponse(string $tag, boolean $dontParse = false) : null | boolean | array

Parameters

$tag

string

the tag of your request

$dontParse

boolean

if true every line is returned unparsed instead of the decoded tokens

Exceptions

\Zend_Mail_Protocol_Exception

Returns

nullbooleanarraytokens if success, false if error, null if bad request

rename an existing folder

rename(string $old, string $new) : boolean

Parameters

$old

string

old name

$new

string

new name

Returns

booleansuccess

send a request and get response at once

requestAndResponse(string $command, array $tokens = array(), boolean $dontParse = false) : mixed

Parameters

$command

string

command as in sendRequest()

$tokens

array

parameters as in sendRequest()

$dontParse

boolean

if true unparsed lines are returned instead of tokens

Exceptions

\Zend_Mail_Protocol_Exception

Returns

mixedresponse as in readResponse()

change folder

select(string $box = 'INBOX') : boolean | array

Parameters

$box

string

change to this folder

Exceptions

\Zend_Mail_Protocol_Exception

Returns

booleanarraysee examineOrselect()

send a request

sendRequest(string $command, array $tokens = array(), string $tag = null) : null

Parameters

$command

string

your request command

$tokens

array

additional parameters to command, use escapeString() to prepare

$tag

string

provide a tag otherwise an autogenerated is returned

Exceptions

\Zend_Mail_Protocol_Exception

Returns

null

set flags

store(array $flags, integer $from, integer|null $to = null, string|null $mode = null, boolean $silent = true) : boolean | array

Parameters

$flags

array

flags to set, add or remove - see $mode

$from

integer

message for items or start message if $to !== null

$to

integernull

if null only one message ($from) is fetched, else it's the last message, INF means last message avaible

$mode

stringnull

'+' to add flags, '-' to remove flags, everything else sets the flags as given

$silent

boolean

if false the return values are the new flags for the wanted messages

Exceptions

\Zend_Mail_Protocol_Exception

Returns

booleanarraynew flags if $silent is false, else true or false depending on success

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.

_assumedNextLine(string $start) : boolean

Parameters

$start

string

the first bytes we assume to be in the next line

Exceptions

\Zend_Mail_Protocol_Exception

Returns

booleanline starts with $start

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

_decodeLine(string $line) : array

Parameters

$line

string

line to decode

Exceptions

\Zend_Mail_Protocol_Exception

Returns

arraytokens, literals are returned as string, lists as array

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

_nextLine() : string

Exceptions

\Zend_Mail_Protocol_Exception

Returns

stringnext line

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

_nextTaggedLine(string $tag) : string

Parameters

$tag

string

tag of line is returned by reference

Exceptions

\Zend_Mail_Protocol_Exception

Returns

stringnext line

 Properties

 

socket to imap server

$_socket : resource | null

Default

 

counter for request tag

$_tagCount : integer

Default

0

 Constants

 

Default timeout in seconds for initiating session

TIMEOUT_CONNECTION = 30