1482. Class

1482.1. Zend\Mail\Protocol\Imap

1482.1.1. Methods

1482.1.1.1. __construct

__construct()

Public constructor

Parameters:
  • string – hostname or IP address of IMAP server, if given connect() is called
  • int|null – port of IMAP server, null for default (143 or 993 for ssl)
  • bool – use ssl? ‘SSL’, ‘TLS’ or false
Throws ZendMailProtocolExceptionExceptionInterface:
 

1482.1.1.2. __destruct

__destruct()

Public destructor

1482.1.1.3. connect

connect()

Open connection to IMAP server

Parameters:
  • string – hostname or IP address of IMAP server
  • int|null – of IMAP server, default is 143 (993 for ssl)
  • string|bool – use ‘SSL’, ‘TLS’ or false
Throws ExceptionRuntimeException:
 
Return type:

string welcome message

1482.1.1.4. _nextLine

_nextLine()

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

Return type:string next line

1482.1.1.5. _assumedNextLine

_assumedNextLine()

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 – the first bytes we assume to be in the next line
Return type:bool line starts with $start

1482.1.1.6. _nextTaggedLine

_nextTaggedLine()

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

Parameters:string – tag of line is returned by reference
Return type:string next line

1482.1.1.7. _decodeLine

_decodeLine()

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

Parameters:string – line to decode
Return type:array tokens, literals are returned as string, lists as array

1482.1.1.8. readLine

readLine()

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

Parameters:
  • array|string – decoded tokens are returned by reference, if $dontParse is true the unparsed line is returned here
  • string – check for this tag for response code. Default ‘*’ is continuation tag.
  • bool – if true only the unparsed line is returned $tokens
Return type:

bool if returned tag matches wanted tag

1482.1.1.9. readResponse

readResponse()

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

Parameters:
  • string – the tag of your request
  • bool – if true every line is returned unparsed instead of the decoded tokens
Return type:

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

1482.1.1.10. sendRequest

sendRequest()

send a request

Parameters:
  • string – your request command
  • array – additional parameters to command, use escapeString() to prepare
  • string – provide a tag otherwise an autogenerated is returned
Throws ExceptionRuntimeException:
 

1482.1.1.11. requestAndResponse

requestAndResponse()

send a request and get response at once

Parameters:
  • string – command as in sendRequest()
  • array – parameters as in sendRequest()
  • bool – if true unparsed lines are returned instead of tokens
Return type:

mixed response as in readResponse()

1482.1.1.12. escapeString

escapeString()

escape one or more literals i.e. for sendRequest

Parameters:string|array – the literal/-s
Return type:string|array escape literals, literals with newline ar returned as array(‘{size}’, ‘string’);

1482.1.1.13. escapeList

escapeList()

escape a list with literals or lists

Parameters:array – list with literals or lists as PHP array
Return type:string escaped list for imap

1482.1.1.14. login

login()

Login to IMAP server.

Parameters:
  • string – username
  • string – password
Return type:

bool success

1482.1.1.15. logout

logout()

logout of imap server

Return type:bool success

1482.1.1.16. capability

capability()

Get capabilities from IMAP server

Return type:array list of capabilities
Throws :ZendMailProtocolExceptionExceptionInterface

1482.1.1.17. examineOrSelect

examineOrSelect()

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

Parameters:
  • string – can be ‘EXAMINE’ or ‘SELECT’ and this is used as command
  • string – which folder to change to or examine
Return type:

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

Throws :

ZendMailProtocolExceptionExceptionInterface

1482.1.1.18. select

select()

change folder

Parameters:string – change to this folder
Return type:bool|array see examineOrselect()
Throws :ZendMailProtocolExceptionExceptionInterface

1482.1.1.19. examine

examine()

examine folder

Parameters:string – examine this folder
Return type:bool|array see examineOrselect()
Throws :ZendMailProtocolExceptionExceptionInterface

1482.1.1.20. fetch

fetch()

fetch one or more items of one or more messages

Parameters:
  • string|array – items to fetch from message(s) as string (if only one item) or array of strings
  • int|array – message for items or start message if $to !== null
  • int|null – if null only one message ($from) is fetched, else it’s the last message, INF means last message available
Throws ExceptionRuntimeException:
 
Return type:

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

1482.1.1.21. listMailbox

listMailbox()

get mailbox list

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

Parameters:
  • string – mailbox reference for list
  • string – mailbox name match with wildcards
Return type:

array mailboxes that matched $mailbox as array(globalName => array(‘delim’ => .., ‘flags’ => ..))

Throws :

ZendMailProtocolExceptionExceptionInterface

1482.1.1.22. store

store()

set flags

Parameters:
  • array – flags to set, add or remove - see $mode
  • int – message for items or start message if $to !== null
  • int|null – if null only one message ($from) is fetched, else it’s the last message, INF means last message available
  • string|null – ‘+’ to add flags, ‘-‘ to remove flags, everything else sets the flags as given
  • bool – if false the return values are the new flags for the wanted messages
Return type:

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

Throws :

ZendMailProtocolExceptionExceptionInterface

1482.1.1.23. append

append()

append a new message to given folder

Parameters:
  • string – name of target folder
  • string – full message content
  • array – flags for new message
  • string – date for new message
Return type:

bool success

Throws :

ZendMailProtocolExceptionExceptionInterface

1482.1.1.24. copy

copy()

copy message set from current folder to other folder

Parameters:
  • string – destination folder
  • $from
  • int|null – if null only one message ($from) is fetched, else it’s the last message, INF means last message available
Return type:

bool success

1482.1.1.25. create

create()

create a new folder (and parent folders if needed)

Parameters:string – folder name
Return type:bool success

1482.1.1.26. rename

rename()

rename an existing folder

Parameters:
  • string – old name
  • string – new name
Return type:

bool success

1482.1.1.27. delete

delete()

remove a folder

Parameters:string – folder name
Return type:bool success

1482.1.1.28. expunge

expunge()

permanently remove messages

Return type:bool success

1482.1.1.29. noop

noop()

send noop

Return type:bool success

1482.1.2. Constants

1482.1.2.1. TIMEOUT_CONNECTION

Default timeout in seconds for initiating session