category Zend
package Zend_Mail
subpackage Protocol

 Methods

Public constructor

__construct(string $host, int | null $port, bool $ssl) 

Parameters

$host

string

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

$port

intnull

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

$ssl

bool

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

Exceptions

\Zend\Mail\Protocol\Exception\ExceptionInterface

Public destructor

__destruct() 

append a new message to given folder

append(string $folder, string $message, array $flags, string $date) : bool

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\ExceptionInterface

Returns

boolsuccess

Get capabilities from IMAP server

capability() : array

Exceptions

\Zend\Mail\Protocol\Exception\ExceptionInterface

Returns

arraylist of capabilities

Open connection to IMAP server

connect(string $host, int | null $port, string | bool $ssl) : string

Parameters

$host

string

hostname or IP address of IMAP server

$port

intnull

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

$ssl

stringbool

use 'SSL', 'TLS' or false

Exceptions

\Zend\Mail\Protocol\Exception\RuntimeException

Returns

stringwelcome message

copy message set from current folder to other folder

copy(string $folder, $from, int | null $to) : bool

Parameters

$folder

string

destination folder

$from

$to

intnull

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

Returns

boolsuccess

create a new folder (and parent folders if needed)

create(string $folder) : bool

Parameters

$folder

string

folder name

Returns

boolsuccess

remove a folder

delete(string $folder) : bool

Parameters

$folder

string

folder name

Returns

boolsuccess

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.

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

for sendRequest

Parameters

$string

stringarray

the literal/-s

Returns

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

examine folder

examine(string $box) : bool | array

Parameters

$box

string

examine this folder

Exceptions

\Zend\Mail\Protocol\Exception\ExceptionInterface

Returns

boolarraysee examineOrselect()

Examine and select have the same response.

examineOrSelect(string $command, string $box) : bool | array

The common code for both is in this method

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\ExceptionInterface

Returns

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

permanently remove messages

expunge() : bool

Returns

boolsuccess

fetch one or more items of one or more messages

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

Parameters

$items

stringarray

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

$from

intarray

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

$to

intnull

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

Exceptions

\Zend\Mail\Protocol\Exception\RuntimeException

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 fetched 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\ExceptionInterface

Returns

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

logout of imap server

logout() : bool

Returns

boolsuccess

send noop

noop() : bool

Returns

boolsuccess

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

readLine(array | string $tokens, string $wantedTag, bool $dontParse) : bool

.}) 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

bool

if true only the unparsed line is returned $tokens

Returns

boolif returned tag matches wanted tag

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

readResponse(string $tag, bool $dontParse) : null | bool | array

Parameters

$tag

string

the tag of your request

$dontParse

bool

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

Returns

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

rename an existing folder

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

Parameters

$old

string

old name

$new

string

new name

Returns

boolsuccess

send a request and get response at once

requestAndResponse(string $command, array $tokens, bool $dontParse) : mixed

Parameters

$command

string

command as in sendRequest()

$tokens

array

parameters as in sendRequest()

$dontParse

bool

if true unparsed lines are returned instead of tokens

Returns

mixedresponse as in readResponse()

change folder

select(string $box) : bool | array

Parameters

$box

string

change to this folder

Exceptions

\Zend\Mail\Protocol\Exception\ExceptionInterface

Returns

boolarraysee examineOrselect()

send a request

sendRequest(string $command, array $tokens, string $tag) 

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\RuntimeException

set flags

store(array $flags, int $from, int | null $to, string | null $mode, bool $silent) : bool | array

Parameters

$flags

array

flags to set, add or remove - see $mode

$from

int

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

$to

intnull

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

$mode

stringnull

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

$silent

bool

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

Exceptions

\Zend\Mail\Protocol\Exception\ExceptionInterface

Returns

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

get next line and assume it starts with $start.

_assumedNextLine(string $start) : bool

some requests give a simple feedback so we can quickly check if we can go on.

Parameters

$start

string

the first bytes we assume to be in the next line

Returns

boolline starts with $start

split a given line in tokens.

_decodeLine(string $line) : array

a token is literal of any form or a list

Parameters

$line

string

line to decode

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\RuntimeException

Returns

stringnext line

get next line and split the tag.

_nextTaggedLine(string $tag) : string

that's the normal case for a response line

Parameters

$tag

string

tag of line is returned by reference

Returns

stringnext line

 Properties

 

socket to imap server

$socket : resource | null

 

counter for request tag

$tagCount : int

 Constants

 

Default timeout in seconds for initiating session

TIMEOUT_CONNECTION