package Default

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

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

Returns

booleansuccess

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

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 available

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

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

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|array $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

integerarray

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 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() : 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

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

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

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

Returns

booleanarraysee examineOrselect()

send a request

sendRequest(string $command, array $tokens = array(), string $tag = 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\RuntimeException

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 available

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

Returns

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

subscribe to a folder

subscribe(string $folder) : boolean

Parameters

$folder

string

folder name

Returns

booleansuccess

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

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

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. that's the normal case for a response line

_nextTaggedLine(string $tag) : string

Parameters

$tag

string

tag of line is returned by reference

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