Mail/Protocol/Imap.php

Show: PublicProtectedPrivateinherited
Table of Contents
Zend Framework
LICENSE This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Mail  
Subpackage
Protocol  
Version
$Id$  

\Zend_Mail_Protocol_Imap

Package: Zend_Mail\Protocol
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Constants

>VConstant  TIMEOUT_CONNECTION = 30
Default timeout in seconds for initiating session

Properties

>VPropertyprotectedresource|null $_socket
socket to imap server
Details
Type
resource | null
>VPropertyprotectedint $_tagCount = 0
counter for request tag
Default value0Details
Type
int

Methods

methodpublic__construct(string $host = '', int | null $port = null, bool $ssl = false) : void

Public constructor

Parameters
NameTypeDescription
$hoststring

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

$portint | null

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

$sslbool

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

Throws
ExceptionDescription
\Zend_Mail_Protocol_Exception
methodpublic__destruct() : void

Public destructor

methodprotected_assumedNextLine(string $start) : bool

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
NameTypeDescription
$startstring

the first bytes we assume to be in the next line

Returns
TypeDescription
boolline starts with $start
Throws
ExceptionDescription
\Zend_Mail_Protocol_Exception
methodprotected_decodeLine(string $line) : array

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

Parameters
NameTypeDescription
$linestring

line to decode

Returns
TypeDescription
arraytokens, literals are returned as string, lists as array
Throws
ExceptionDescription
\Zend_Mail_Protocol_Exception
methodprotected_nextLine() : string

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

Returns
TypeDescription
stringnext line
Throws
ExceptionDescription
\Zend_Mail_Protocol_Exception
methodprotected_nextTaggedLine(string $tag) : string

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

Parameters
NameTypeDescription
$tagstring

tag of line is returned by reference

Returns
TypeDescription
stringnext line
Throws
ExceptionDescription
\Zend_Mail_Protocol_Exception
methodpublicappend(string $folder, string $message, array $flags = null, string $date = null) : bool

append a new message to given folder

Parameters
NameTypeDescription
$folderstring

name of target folder

$messagestring

full message content

$flagsarray

flags for new message

$datestring

date for new message

Returns
TypeDescription
boolsuccess
Throws
ExceptionDescription
\Zend_Mail_Protocol_Exception
methodpubliccapability() : array

Get capabilities from IMAP server

Returns
TypeDescription
arraylist of capabilities
Throws
ExceptionDescription
\Zend_Mail_Protocol_Exception
methodpublicconnect(string $host, int | null $port = null, string | bool $ssl = false) : string

Open connection to IMAP server

Parameters
NameTypeDescription
$hoststring

hostname or IP address of IMAP server

$portint | null

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

$sslstring | bool

use 'SSL', 'TLS' or false

Returns
TypeDescription
stringwelcome message
Throws
ExceptionDescription
\Zend_Mail_Protocol_Exception
methodpubliccopy(string $folder,  $from, int | null $to = null) : bool

copy message set from current folder to other folder

Parameters
NameTypeDescription
$folderstring

destination folder

$from
$toint | null

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

                    last message, INF means last message avaible
Returns
TypeDescription
boolsuccess
Throws
ExceptionDescription
\Zend_Mail_Protocol_Exception
methodpubliccreate(string $folder) : bool

create a new folder (and parent folders if needed)

Parameters
NameTypeDescription
$folderstring

folder name

Returns
TypeDescription
boolsuccess
methodpublicdelete(string $folder) : bool

remove a folder

Parameters
NameTypeDescription
$folderstring

folder name

Returns
TypeDescription
boolsuccess
methodpublicescapeList(array $list) : string

escape a list with literals or lists

Parameters
NameTypeDescription
$listarray

list with literals or lists as PHP array

Returns
TypeDescription
stringescaped list for imap
methodpublicescapeString(string | array $string) : string | array

escape one or more literals i.e. for sendRequest

Parameters
NameTypeDescription
$stringstring | array

the literal/-s

Returns
TypeDescription
string | arrayescape literals, literals with newline ar returned as array('{size}', 'string');
methodpublicexamine(string $box = 'INBOX') : bool | array

examine folder

Parameters
NameTypeDescription
$boxstring

examine this folder

Returns
TypeDescription
bool | arraysee examineOrselect()
Throws
ExceptionDescription
\Zend_Mail_Protocol_Exception
methodpublicexamineOrSelect(string $command = 'EXAMINE', string $box = 'INBOX') : bool | array

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

Parameters
NameTypeDescription
$commandstring

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

$boxstring

which folder to change to or examine

Returns
TypeDescription
bool | arrayfalse if error, array with returned information otherwise (flags, exists, recent, uidvalidity)
Throws
ExceptionDescription
\Zend_Mail_Protocol_Exception
methodpublicexpunge() : bool

permanently remove messages

Returns
TypeDescription
boolsuccess
methodpublicfetch(string | array $items, int $from, int | null $to = null) : string | array

fetch one or more items of one or more messages

Parameters
NameTypeDescription
$itemsstring | array

items to fetch from message(s) as string (if only one item)

                        or array of strings
$fromint

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

$toint | null

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

                        last message, INF means last message avaible
Returns
TypeDescription
string | arrayif 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))
Throws
ExceptionDescription
\Zend_Mail_Protocol_Exception
methodpubliclistMailbox(string $reference = '', string $mailbox = '*') : array

get mailbox list

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

mailbox reference for list

$mailboxstring

mailbox name match with wildcards

Returns
TypeDescription
arraymailboxes that matched $mailbox as array(globalName => array('delim' => .., 'flags' => ..))
Throws
ExceptionDescription
\Zend_Mail_Protocol_Exception
methodpubliclogin(string $user, string $password) : bool

Login to IMAP server.

Parameters
NameTypeDescription
$userstring

username

$passwordstring

password

Returns
TypeDescription
boolsuccess
Throws
ExceptionDescription
\Zend_Mail_Protocol_Exception
methodpubliclogout() : bool

logout of imap server

Returns
TypeDescription
boolsuccess
methodpublicnoop() : bool

send noop

Returns
TypeDescription
boolsuccess
methodpublicreadLine(array | string $tokens = array(), string $wantedTag = '*', bool $dontParse = false) : bool

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

.}) and do a simple decode
Parameters
NameTypeDescription
$tokensarray | string

decoded tokens are returned by reference, if $dontParse

                             is true the unparsed line is returned here
$wantedTagstring

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

                             continuation tag.
$dontParsebool

if true only the unparsed line is returned $tokens

Returns
TypeDescription
boolif returned tag matches wanted tag
Throws
ExceptionDescription
\Zend_Mail_Protocol_Exception
methodpublicreadResponse(string $tag, bool $dontParse = false) : null | bool | array

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

Parameters
NameTypeDescription
$tagstring

the tag of your request

$dontParsebool

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

Returns
TypeDescription
null | bool | arraytokens if success, false if error, null if bad request
Throws
ExceptionDescription
\Zend_Mail_Protocol_Exception
methodpublicrename(string $old, string $new) : bool

rename an existing folder

Parameters
NameTypeDescription
$oldstring

old name

$newstring

new name

Returns
TypeDescription
boolsuccess
methodpublicrequestAndResponse(string $command, array $tokens = array(), bool $dontParse = false) : mixed

send a request and get response at once

Parameters
NameTypeDescription
$commandstring

command as in sendRequest()

$tokensarray

parameters as in sendRequest()

$dontParsebool

if true unparsed lines are returned instead of tokens

Returns
TypeDescription
mixedresponse as in readResponse()
Throws
ExceptionDescription
\Zend_Mail_Protocol_Exception
methodpublicselect(string $box = 'INBOX') : bool | array

change folder

Parameters
NameTypeDescription
$boxstring

change to this folder

Returns
TypeDescription
bool | arraysee examineOrselect()
Throws
ExceptionDescription
\Zend_Mail_Protocol_Exception
methodpublicsendRequest(string $command, array $tokens = array(), string $tag = null) : null

send a request

Parameters
NameTypeDescription
$commandstring

your request command

$tokensarray

additional parameters to command, use escapeString() to prepare

$tagstring

provide a tag otherwise an autogenerated is returned

Returns
TypeDescription
null
Throws
ExceptionDescription
\Zend_Mail_Protocol_Exception
methodpublicstore(array $flags, int $from, int | null $to = null, string | null $mode = null, bool $silent = true) : bool | array

set flags

Parameters
NameTypeDescription
$flagsarray

flags to set, add or remove - see $mode

$fromint

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

$toint | null

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

                        last message, INF means last message avaible
$modestring | null

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

$silentbool

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

Returns
TypeDescription
bool | arraynew flags if $silent is false, else true or false depending on success
Throws
ExceptionDescription
\Zend_Mail_Protocol_Exception
Documentation was generated by phpDocumentor 2.2.0 .