API Documentation

Zend/Mail/Protocol/Imap.php

Show: inherited
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-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Mail  
Subpackage
Protocol  
Version
$Id: Imap.php 24594 2012-01-05 21:27:01Z matthew $  

\Zend_Mail_Protocol_Imap

Package: Zend\Mail\Protocol

Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Constants

Constant  TIMEOUT_CONNECTION = 30

Default timeout in seconds for initiating session

Properties

Propertyprotectedresource|null  $_socket= ''

socket to imap server

Details
Type
resourcenull
Propertyprotectedint  $_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
Name Type Description
$host string

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

$port int|null

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

$ssl bool

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

Throws
Exception Description
\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
Name Type Description
$start string

the first bytes we assume to be in the next line

Returns
Type Description
bool line starts with $start
Throws
Exception Description
\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
Name Type Description
$line string

line to decode

Returns
Type Description
array tokens, literals are returned as string, lists as array
Throws
Exception Description
\Zend_Mail_Protocol_Exception
methodprotected_nextLine( ) : string

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

Returns
Type Description
string next line
Throws
Exception Description
\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
Name Type Description
$tag string

tag of line is returned by reference

Returns
Type Description
string next line
Throws
Exception Description
\Zend_Mail_Protocol_Exception
methodpublicappend( string $folder, string $message, array $flags = null, string $date = null ) : bool

append a new message to given folder

Parameters
Name Type Description
$folder string

name of target folder

$message string

full message content

$flags array

flags for new message

$date string

date for new message

Returns
Type Description
bool success
Throws
Exception Description
\Zend_Mail_Protocol_Exception
methodpubliccapability( ) : array

Get capabilities from IMAP server

Returns
Type Description
array list of capabilities
Throws
Exception Description
\Zend_Mail_Protocol_Exception
methodpublicconnect( string $host, int|null $port = null, string|bool $ssl = false ) : string

Open connection to IMAP server

Parameters
Name Type Description
$host string

hostname or IP address of IMAP server

$port int|null

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

$ssl string|bool

use 'SSL', 'TLS' or false

Returns
Type Description
string welcome message
Throws
Exception Description
\Zend_Mail_Protocol_Exception
methodpubliccopy( string $folder,  $from, int|null $to = null ) : bool

copy message set from current folder to other folder

Parameters
Name Type Description
$folder string

destination folder

$from
$to int|null

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

Returns
Type Description
bool success
Throws
Exception Description
\Zend_Mail_Protocol_Exception
methodpubliccreate( string $folder ) : bool

create a new folder (and parent folders if needed)

Parameters
Name Type Description
$folder string

folder name

Returns
Type Description
bool success
methodpublicdelete( string $folder ) : bool

remove a folder

Parameters
Name Type Description
$folder string

folder name

Returns
Type Description
bool success
methodpublicescapeList( array $list ) : string

escape a list with literals or lists

Parameters
Name Type Description
$list array

list with literals or lists as PHP array

Returns
Type Description
string escaped list for imap
methodpublicescapeString( string|array $string ) : string|array

escape one or more literals i.e. for sendRequest

Parameters
Name Type Description
$string string|array

the literal/-s

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

examine folder

Parameters
Name Type Description
$box string

examine this folder

Returns
Type Description
bool|array see examineOrselect()
Throws
Exception Description
\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
Name Type Description
$command string

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

$box string

which folder to change to or examine

Returns
Type Description
bool|array false if error, array with returned information otherwise (flags, exists, recent, uidvalidity)
Throws
Exception Description
\Zend_Mail_Protocol_Exception
methodpublicexpunge( ) : bool

permanently remove messages

Returns
Type Description
bool success
methodpublicfetch( string|array $items, int $from, int|null $to = null ) : string|array

fetch one or more items of one or more messages

Parameters
Name Type Description
$items string|array

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

$from int

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

$to int|null

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

Returns
Type Description
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 fetchted it's returned as (msgno => (name => value))
Throws
Exception Description
\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
Name Type Description
$reference string

mailbox reference for list

$mailbox string

mailbox name match with wildcards

Returns
Type Description
array mailboxes that matched $mailbox as array(globalName => array('delim' => .., 'flags' => ..))
Throws
Exception Description
\Zend_Mail_Protocol_Exception
methodpubliclogin( string $user, string $password ) : bool

Login to IMAP server.

Parameters
Name Type Description
$user string

username

$password string

password

Returns
Type Description
bool success
Throws
Exception Description
\Zend_Mail_Protocol_Exception
methodpubliclogout( ) : bool

logout of imap server

Returns
Type Description
bool success
methodpublicnoop( ) : bool

send noop

Returns
Type Description
bool success
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
Name Type Description
$tokens array|string

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
Type Description
bool if returned tag matches wanted tag
Throws
Exception Description
\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
Name Type Description
$tag string

the tag of your request

$dontParse bool

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

Returns
Type Description
null|bool|array tokens if success, false if error, null if bad request
Throws
Exception Description
\Zend_Mail_Protocol_Exception
methodpublicrename( string $old, string $new ) : bool

rename an existing folder

Parameters
Name Type Description
$old string

old name

$new string

new name

Returns
Type Description
bool success
methodpublicrequestAndResponse( string $command, array $tokens = array(), bool $dontParse = false ) : mixed

send a request and get response at once

Parameters
Name Type Description
$command string

command as in sendRequest()

$tokens array

parameters as in sendRequest()

$dontParse bool

if true unparsed lines are returned instead of tokens

Returns
Type Description
mixed response as in readResponse()
Throws
Exception Description
\Zend_Mail_Protocol_Exception
methodpublicselect( string $box = 'INBOX' ) : bool|array

change folder

Parameters
Name Type Description
$box string

change to this folder

Returns
Type Description
bool|array see examineOrselect()
Throws
Exception Description
\Zend_Mail_Protocol_Exception
methodpublicsendRequest( string $command, array $tokens = array(), string $tag = null ) : null

send a request

Parameters
Name Type Description
$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

Returns
Type Description
null
Throws
Exception Description
\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
Name Type Description
$flags array

flags to set, add or remove - see $mode

$from int

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

$to int|null

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

$mode string|null

'+' 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

Returns
Type Description
bool|array new flags if $silent is false, else true or false depending on success
Throws
Exception Description
\Zend_Mail_Protocol_Exception
Documentation was generated by DocBlox 0.15.1.