API Documentation

Mail/Protocol/Imap.php

Classes 
category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Mail
subpackage
Protocol
version
$Id: Imap.php 20096 2010-01-06 02:05:09Z bkarwin $
Classes
Zend_Mail_Protocol_Imap

Description

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.

Zend_Mail_Protocol_Imap

category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Mail
subpackage
Protocol
Constants
TIMEOUT_CONNECTION
Properties
$_socket
$_tagCount
Methods
__construct
__destruct
connect
_nextLine
_assumedNextLine
_nextTaggedLine
_decodeLine
readLine
readResponse
sendRequest
requestAndResponse
escapeString
escapeList
login
logout
capability
examineOrSelect
select
examine
fetch
listMailbox
store
append
copy
create
rename
delete
expunge
noop
search

Description

Constants

TIMEOUT_CONNECTION

 TIMEOUT_CONNECTION = '30'

Default timeout in seconds for initiating session

Details

value
30

Properties

$_socket

resource|null $_socket = ''

socket to imap server

Details

$_socket
resource|null
visibility
protected
default
final
false
static
false

$_tagCount

int $_tagCount = '0'

counter for request tag

Details

$_tagCount
int
visibility
protected
default
0
final
false
static
false

Methods

__construct

__construct( string $host, int|null $port = null, bool $ssl = false ) :

Public constructor

Arguments
$host
string
hostname or IP address of IMAP server, if given connect() is called
$port
intnull
port of IMAP server, null for default (143 or 993 for ssl)
$ssl
bool
use ssl? 'SSL', 'TLS' or false
Details
visibility
public
final
false
static
false
throws

__destruct

__destruct( ) :

Public destructor

Details
visibility
public
final
false
static
false

_assumedNextLine

_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.

Arguments
$start
string
the first bytes we assume to be in the next line
Output
bool
line starts with $start
Details
visibility
protected
final
false
static
false
throws

_decodeLine

_decodeLine( string $line ) : array

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

Arguments
$line
string
line to decode
Output
array
tokens, literals are returned as string, lists as array
Details
visibility
protected
final
false
static
false
throws

_nextLine

_nextLine( ) : string

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

Output
string
next line
Details
visibility
protected
final
false
static
false
throws

_nextTaggedLine

_nextTaggedLine( string $tag ) : string

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

Arguments
$tag
string
tag of line is returned by reference
Output
string
next line
Details
visibility
protected
final
false
static
false
throws

append

append( string $folder, string $message, array $flags = null, string $date = null ) : bool

append a new message to given folder

Arguments
$folder
string
name of target folder
$message
string
full message content
$flags
array
flags for new message
$date
string
date for new message
Output
bool
success
Details
visibility
public
final
false
static
false
throws

capability

capability( ) : array

Get capabilities from IMAP server

Output
array
list of capabilities
Details
visibility
public
final
false
static
false
throws

connect

connect( string $host, int|null $port = null, string|bool $ssl = false ) : string

Open connection to IMAP server

Arguments
$host
string
hostname or IP address of IMAP server
$port
intnull
of IMAP server, default is 143 (993 for ssl)
$ssl
stringbool
use 'SSL', 'TLS' or false
Output
string
welcome message
Details
visibility
public
final
false
static
false
throws

copy

copy( string $folder,  $from, int|null $to = null ) : bool

copy message set from current folder to other folder

Arguments
$folder
string
destination folder
$from
$to
intnull
if null only one message ($from) is fetched, else it's the last message, INF means last message avaible
Output
bool
success
Details
visibility
public
final
false
static
false
throws

create

create( string $folder ) : bool

create a new folder (and parent folders if needed)

Arguments
$folder
string
folder name
Output
bool
success
Details
visibility
public
final
false
static
false

delete

delete( string $folder ) : bool

remove a folder

Arguments
$folder
string
folder name
Output
bool
success
Details
visibility
public
final
false
static
false

escapeList

escapeList( array $list ) : string

escape a list with literals or lists

Arguments
$list
array
list with literals or lists as PHP array
Output
string
escaped list for imap
Details
visibility
public
final
false
static
false

escapeString

escapeString( string|array $string ) : string|array

escape one or more literals i.e. for sendRequest

Arguments
$string
stringarray
the literal/-s
Output
string|array
escape literals, literals with newline ar returned as array('{size}', 'string');
Details
visibility
public
final
false
static
false

examine

examine( string $box = INBOX ) : bool|array

examine folder

Arguments
$box
string
examine this folder
Output
bool|array
see examineOrselect()
Details
visibility
public
final
false
static
false
throws

examineOrSelect

examineOrSelect( string $command = EXAMINE, string $box = INBOX ) : bool|array

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

Arguments
$command
string
can be 'EXAMINE' or 'SELECT' and this is used as command
$box
string
which folder to change to or examine
Output
bool|array
false if error, array with returned information otherwise (flags, exists, recent, uidvalidity)
Details
visibility
public
final
false
static
false
throws

expunge

expunge( ) : bool

permanently remove messages

Output
bool
success
Details
visibility
public
final
false
static
false

fetch

fetch( string|array $items, int $from, int|null $to = null ) : string|array

fetch one or more items of one or more messages

Arguments
$items
stringarray
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
intnull
if null only one message ($from) is fetched, else it's the last message, INF means last message avaible
Output
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))
Details
visibility
public
final
false
static
false
throws

listMailbox

listMailbox( 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

Arguments
$reference
string
mailbox reference for list
$mailbox
string
mailbox name match with wildcards
Output
array
mailboxes that matched $mailbox as array(globalName => array('delim' => .., 'flags' => ..))
Details
visibility
public
final
false
static
false
throws

login

login( string $user, string $password ) : bool

Login to IMAP server.

Arguments
$user
string
username
$password
string
password
Output
bool
success
Details
visibility
public
final
false
static
false
throws

logout

logout( ) : bool

logout of imap server

Output
bool
success
Details
visibility
public
final
false
static
false

noop

noop( ) : bool

send noop

Output
bool
success
Details
visibility
public
final
false
static
false

readLine

readLine( 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 {..}<NL>) and do a simple decode

Arguments
$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 &#039;*&#039; is continuation tag.
$dontParse
bool
if true only the unparsed line is returned $tokens
Output
bool
if returned tag matches wanted tag
Details
visibility
public
final
false
static
false
throws

readResponse

readResponse( string $tag, bool $dontParse = false ) : null|bool|array

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

Arguments
$tag
string
the tag of your request
$dontParse
bool
if true every line is returned unparsed instead of the decoded tokens
Output
null|bool|array
tokens if success, false if error, null if bad request
Details
visibility
public
final
false
static
false
throws

rename

rename( string $old, string $new ) : bool

rename an existing folder

Arguments
$old
string
old name
$new
string
new name
Output
bool
success
Details
visibility
public
final
false
static
false

requestAndResponse

requestAndResponse( string $command, array $tokens = array, bool $dontParse = false ) : mixed

send a request and get response at once

Arguments
$command
string
command as in sendRequest()
$tokens
array
parameters as in sendRequest()
$dontParse
bool
if true unparsed lines are returned instead of tokens
Output
mixed
response as in readResponse()
Details
visibility
public
final
false
static
false
throws

search

search(  $params ) : array

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.

Arguments
$params
Output
array
message ids
Details
visibility
public
final
false
static
false
internal

select

select( string $box = INBOX ) : bool|array

change folder

Arguments
$box
string
change to this folder
Output
bool|array
see examineOrselect()
Details
visibility
public
final
false
static
false
throws

sendRequest

sendRequest( string $command, array $tokens = array, string $tag = null ) : null

send a request

Arguments
$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
Output
null
Details
visibility
public
final
false
static
false
throws

store

store( array $flags, int $from, int|null $to = null, string|null $mode = null, bool $silent = true ) : bool|array

set flags

Arguments
$flags
array
flags to set, add or remove - see $mode
$from
int
message for items or start message if $to !== null
$to
intnull
if null only one message ($from) is fetched, else it&#039;s the last message, INF means last message avaible
$mode
stringnull
&#039;+&#039; to add flags, &#039;-&#039; 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
Output
bool|array
new flags if $silent is false, else true or false depending on success
Details
visibility
public
final
false
static
false
throws
Documentation was generated by DocBlox.