Class Imap

Summary

Fully Qualified Name: Zend\Mail\Protocol\Imap

Description

Methods

Name Description Defined By
__construct() Public constructor Imap
__destruct() Public destructor Imap
append() append a new message to given folder Imap
capability() Get capabilities from IMAP server Imap
connect() Open connection to IMAP server Imap
copy() copy message set from current folder to other folder Imap
create() create a new folder (and parent folders if needed) Imap
delete() remove a folder Imap
escapeList() escape a list with literals or lists Imap
escapeString() escape one or more literals i.e. for sendRequest Imap
examine() examine folder Imap
examineOrSelect() Examine and select have the same response. The common code for both is in this method Imap
expunge() permanently remove messages Imap
fetch() fetch one or more items of one or more messages Imap
listMailbox() get mailbox list Imap
login() Login to IMAP server. Imap
logout() logout of imap server Imap
noop() send noop Imap
readLine() read a response "line" (could also be more than one real line if response has {. Imap
readResponse() read all lines of response until given tag is found (last line of response) Imap
rename() rename an existing folder Imap
requestAndResponse() send a request and get response at once Imap
search() do a search request Imap
select() change folder Imap
sendRequest() send a request Imap
store() set flags Imap
subscribe() subscribe to a folder Imap

Method Details

__construct()

Public constructor

Parameter Name Type Description
$host string hostname
$port int|null port
$ssl bool use

Returns:

__destruct()

Public destructor

Returns:

append()

append a new message to given folder

Parameter Name Type Description
$folder string name
$message string full
$flags array flags
$date string date

Returns: bool success

capability()

Get capabilities from IMAP server

Returns: array list of capabilities

connect()

Open connection to IMAP server

Parameter Name Type Description
$host string hostname
$port int|null of
$ssl string|bool use

Returns: string welcome message

copy()

copy message set from current folder to other folder

Parameter Name Type Description
$folder string destination
$from
$to int|null if
$from

Returns: bool success

create()

create a new folder (and parent folders if needed)

Parameter Name Type Description
$folder string folder

Returns: bool success

delete()

remove a folder

Parameter Name Type Description
$folder string folder

Returns: bool success

escapeList()

escape a list with literals or lists

Parameter Name Type Description
$list array list

Returns: string escaped list for imap

escapeString()

escape one or more literals i.e. for sendRequest

Parameter Name Type Description
$string string|array the

Returns: string|array escape literals, literals with newline ar returned as array('{size}', 'string');

examine()

examine folder

Parameter Name Type Description
$box string examine

Returns: bool|array see examineOrselect()

examineOrSelect()

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

Parameter Name Type Description
$command string can
$box string which

Returns: bool|array false if error, array with returned information otherwise (flags, exists, recent, uidvalidity)

expunge()

permanently remove messages

Returns: bool success

fetch()

fetch one or more items of one or more messages

Parameter Name Type Description
$items string|array items
$from int|array message
$to int|null if
$uid bool set

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 fetched it's returned as (msgno => (name => value))

listMailbox()

get mailbox list

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

Parameter Name Type Description
$reference string mailbox
$mailbox string mailbox

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

login()

Login to IMAP server.

Parameter Name Type Description
$user string username
$password string password

Returns: bool success

logout()

logout of imap server

Returns: bool success

noop()

send noop

Returns: bool success

readLine()

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

.}) and do a simple decode

Parameter Name Type Description
$tokens array|string decoded
$wantedTag string check
$dontParse bool if

Returns: bool if returned tag matches wanted tag

readResponse()

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

Parameter Name Type Description
$tag string the
$dontParse bool if

Returns: null|bool|array tokens if success, false if error, null if bad request

rename()

rename an existing folder

Parameter Name Type Description
$old string old
$new string new

Returns: bool success

requestAndResponse()

send a request and get response at once

Parameter Name Type Description
$command string command
$tokens array parameters
$dontParse bool if

Returns: mixed response as in readResponse()

search()

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.

Parameter Name Type Description
$params array

Returns: array message ids

select()

change folder

Parameter Name Type Description
$box string change

Returns: bool|array see examineOrselect()

sendRequest()

send a request

Parameter Name Type Description
$command string your
$tokens array additional
$tag string provide

Returns:

store()

set flags

Parameter Name Type Description
$flags array flags
$from int message
$to int|null if
$mode string|null '+'
$silent bool if

Returns: bool|array new flags if $silent is false, else true or false depending on success

subscribe()

subscribe to a folder

Parameter Name Type Description
$folder string folder

Returns: bool success

Top