|
| __construct ($host='', $port=null, $ssl=false) |
|
| __destruct () |
|
| connect ($host, $port=null, $ssl=false) |
|
| readLine (&$tokens=array(), $wantedTag=' *', $dontParse=false) |
|
| readResponse ($tag, $dontParse=false) |
|
| sendRequest ($command, $tokens=array(), &$tag=null) |
|
| requestAndResponse ($command, $tokens=array(), $dontParse=false) |
|
| escapeString ($string) |
|
| escapeList ($list) |
|
| login ($user, $password) |
|
| logout () |
|
| capability () |
|
| examineOrSelect ($command='EXAMINE', $box='INBOX') |
|
| select ($box='INBOX') |
|
| examine ($box='INBOX') |
|
| fetch ($items, $from, $to=null) |
|
| listMailbox ($reference='', $mailbox=' *') |
|
| store (array $flags, $from, $to=null, $mode=null, $silent=true) |
|
| append ($folder, $message, $flags=null, $date=null) |
|
| copy ($folder, $from, $to=null) |
|
| create ($folder) |
|
| rename ($old, $new) |
|
| delete ($folder) |
|
| expunge () |
|
| noop () |
|
| search (array $params) |
|
Definition at line 31 of file Imap.php.
◆ __construct()
__construct |
( |
|
$host = '' , |
|
|
|
$port = null , |
|
|
|
$ssl = false |
|
) |
| |
Public constructor
- Parameters
-
string | $host | hostname or IP address of IMAP server, if given connect() is called |
int | null | $port | port of IMAP server, null for default (143 or 993 for ssl) |
bool | $ssl | use ssl? 'SSL', 'TLS' or false |
- Exceptions
-
Definition at line 58 of file Imap.php.
61 $this->
connect($host, $port, $ssl);
connect($host, $port=null, $ssl=false)
◆ __destruct()
Public destructor
Definition at line 68 of file Imap.php.
◆ _assumedNextLine()
_assumedNextLine |
( |
|
$start | ) |
|
|
protected |
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 | $start | the first bytes we assume to be in the next line |
- Returns
- bool line starts with $start
- Exceptions
-
Definition at line 154 of file Imap.php.
157 return strpos($line,
$start) === 0;
◆ _decodeLine()
split a given line in tokens. a token is literal of any form or a list
- Parameters
-
string | $line | line to decode |
- Returns
- array tokens, literals are returned as string, lists as array
- Exceptions
-
Definition at line 184 of file Imap.php.
204 $line = rtrim($line) .
' ';
205 while ((
$pos = strpos($line,
' ')) !==
false) {
207 while (
$token[0] ==
'(') {
213 if (preg_match(
'%^\(*"((.|\\\\|\\")*?)" *%', $line, $matches)) {
215 $line = substr($line, strlen($matches[0]));
220 $endPos = strpos(
$token,
'}');
221 $chars = substr(
$token, 1, $endPos - 1);
222 if (is_numeric($chars)) {
224 while (strlen(
$token) < $chars) {
228 if (strlen(
$token) > $chars) {
229 $line = substr(
$token, $chars);
235 $line = trim($line) .
' ';
244 $braces -= strlen(
$token) + 1;
246 if (rtrim(
$token) !=
'') {
252 while ($braces-- > 0) {
259 $line = substr($line,
$pos + 1);
◆ _nextLine()
get the next line from socket with error checking, but nothing else
- Returns
- string next line
- Exceptions
-
- See also
- Zend_Mail_Protocol_Exception
Definition at line 132 of file Imap.php.
134 $line = @fgets($this->_socket);
135 if ($line ===
false) {
139 #require_once 'Zend/Mail/Protocol/Exception.php';
◆ _nextTaggedLine()
_nextTaggedLine |
( |
& |
$tag | ) |
|
|
protected |
get next line and split the tag. that's the normal case for a response line
- Parameters
-
string | $tag | tag of line is returned by reference |
- Returns
- string next line
- Exceptions
-
Definition at line 167 of file Imap.php.
172 list($tag, $line) = explode(
' ', $line, 2);
◆ append()
append |
( |
|
$folder, |
|
|
|
$message, |
|
|
|
$flags = null , |
|
|
|
$date = null |
|
) |
| |
append a new message to given folder
- Parameters
-
string | $folder | name of target folder |
string | $message | full message content |
array | $flags | flags for new message |
string | $date | date for new message |
- Returns
- bool success
- Exceptions
-
Definition at line 724 of file Imap.php.
728 if ($flags !==
null) {
731 if ($date !==
null) {
requestAndResponse($command, $tokens=array(), $dontParse=false)
◆ capability()
Get capabilities from IMAP server
- Returns
- array list of capabilities
- Exceptions
-
Definition at line 477 of file Imap.php.
485 $capabilities = array();
487 $capabilities = array_merge($capabilities, $line);
489 return $capabilities;
requestAndResponse($command, $tokens=array(), $dontParse=false)
◆ connect()
connect |
( |
|
$host, |
|
|
|
$port = null , |
|
|
|
$ssl = false |
|
) |
| |
Open connection to IMAP server
- Parameters
-
string | $host | hostname or IP address of IMAP server |
int | null | $port | of IMAP server, default is 143 (993 for ssl) |
string | bool | $ssl | use 'SSL', 'TLS' or false |
- Returns
- string welcome message
- Exceptions
-
- See also
- Zend_Mail_Protocol_Exception
-
Zend_Mail_Protocol_Exception
-
Zend_Mail_Protocol_Exception
Definition at line 82 of file Imap.php.
85 $host =
'ssl://' . $host;
89 $port = $ssl ===
'SSL' ? 993 : 143;
94 $this->_socket = @
fsockopen($host, $port, $errno, $errstr, self::TIMEOUT_CONNECTION);
95 if (!$this->_socket) {
99 #require_once 'Zend/Mail/Protocol/Exception.php'; 101 ' (errno = ' . $errno .
' )');
108 #require_once 'Zend/Mail/Protocol/Exception.php'; 112 if ($ssl ===
'TLS') {
115 $result =
$result && stream_socket_enable_crypto($this->_socket,
true, STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT);
120 #require_once 'Zend/Mail/Protocol/Exception.php';
fsockopen(&$errorNumber, &$errorMessage)
requestAndResponse($command, $tokens=array(), $dontParse=false)
◆ copy()
copy |
( |
|
$folder, |
|
|
|
$from, |
|
|
|
$to = null |
|
) |
| |
copy message set from current folder to other folder
- Parameters
-
string | $folder | destination folder |
int | null | $to | if null only one message ($from) is fetched, else it's the last message, INF means last message avaible |
- Returns
- bool success
- Exceptions
-
Definition at line 748 of file Imap.php.
752 $set .=
':' . ($to == INF ?
'*' : (int)$to);
requestAndResponse($command, $tokens=array(), $dontParse=false)
◆ create()
create a new folder (and parent folders if needed)
- Parameters
-
- Returns
- bool success
Definition at line 764 of file Imap.php.
requestAndResponse($command, $tokens=array(), $dontParse=false)
◆ delete()
remove a folder
- Parameters
-
- Returns
- bool success
Definition at line 787 of file Imap.php.
requestAndResponse($command, $tokens=array(), $dontParse=false)
◆ escapeList()
escape a list with literals or lists
- Parameters
-
array | $list | list with literals or lists as PHP array |
- Returns
- string escaped list for imap
Definition at line 423 of file Imap.php.
426 foreach ($list as $k => $v) {
434 return '(' . implode(
' ',
$result) .
')';
◆ escapeString()
escape one or more literals i.e. for sendRequest
- Parameters
-
string | array | $string | the literal/-s |
- Returns
- string|array escape literals, literals with newline ar returned as array('{size}', 'string');
Definition at line 401 of file Imap.php.
403 if (func_num_args() < 2) {
404 if (strpos($string,
"\n") !==
false) {
405 return array(
'{' . strlen($string) .
'}', $string);
407 return '"' . str_replace(array(
'\\',
'"'), array(
'\\\\',
'\\"'), $string) .
'"';
411 foreach (func_get_args() as $string) {
◆ examine()
examine |
( |
|
$box = 'INBOX' | ) |
|
examine folder
- Parameters
-
string | $box | examine this folder |
- Returns
- bool|array see examineOrselect()
- Exceptions
-
Definition at line 551 of file Imap.php.
examineOrSelect($command='EXAMINE', $box='INBOX')
◆ examineOrSelect()
examineOrSelect |
( |
|
$command = 'EXAMINE' , |
|
|
|
$box = 'INBOX' |
|
) |
| |
Examine and select have the same response. The common code for both is in this method
- Parameters
-
string | $command | can be 'EXAMINE' or 'SELECT' and this is used as command |
string | $box | which folder to change to or examine |
- Returns
- bool|array false if error, array with returned information otherwise (flags, exists, recent, uidvalidity)
- Exceptions
-
Definition at line 502 of file Imap.php.
readLine(&$tokens=array(), $wantedTag=' *', $dontParse=false)
sendRequest($command, $tokens=array(), &$tag=null)
◆ expunge()
permanently remove messages
- Returns
- bool success
Definition at line 797 of file Imap.php.
requestAndResponse($command, $tokens=array(), $dontParse=false)
◆ fetch()
fetch |
( |
|
$items, |
|
|
|
$from, |
|
|
|
$to = null |
|
) |
| |
fetch one or more items of one or more messages
- Parameters
-
string | array | $items | items to fetch from message(s) as string (if only one item) or array of strings |
int | $from | message for items or start message if $to !== null |
int | null | $to | if null only one message ($from) is fetched, else it's the last message, INF means last message avaible |
- 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 fetchted it's returned as (msgno => (name => value))
- Exceptions
-
- See also
- Zend_Mail_Protocol_Exception
Definition at line 570 of file Imap.php.
572 if (is_array($from)) {
573 $set = implode(
',', $from);
574 }
else if ($to ===
null) {
576 }
else if ($to === INF) {
577 $set = (int)$from .
':*';
579 $set = (int)$from .
':' . (
int)$to;
585 $this->
sendRequest(
'FETCH', array($set, $itemList), $tag);
594 if ($to ===
null && !is_array($from) &&
$tokens[0] != $from) {
615 while (key(
$tokens[2]) !==
null) {
621 if ($to ===
null && !is_array($from) &&
$tokens[0] == $from) {
629 if ($to ===
null && !is_array($from)) {
633 #require_once 'Zend/Mail/Protocol/Exception.php';
readLine(&$tokens=array(), $wantedTag=' *', $dontParse=false)
sendRequest($command, $tokens=array(), &$tag=null)
◆ listMailbox()
listMailbox |
( |
|
$reference = '' , |
|
|
|
$mailbox = '*' |
|
) |
| |
get mailbox list
this method can't be named after the IMAP command 'LIST', as list is a reserved keyword
- Parameters
-
string | $reference | mailbox reference for list |
string | $mailbox | mailbox name match with wildcards |
- Returns
- array mailboxes that matched $mailbox as array(globalName => array('delim' => .., 'flags' => ..))
- Exceptions
-
Definition at line 650 of file Imap.php.
654 if (!$list || $list ===
true) {
658 foreach ($list as
$item) {
659 if (count(
$item) != 4 ||
$item[0] !=
'LIST') {
requestAndResponse($command, $tokens=array(), $dontParse=false)
◆ login()
login |
( |
|
$user, |
|
|
|
$password |
|
) |
| |
Login to IMAP server.
- Parameters
-
string | $user | username |
string | $password | password |
- Returns
- bool success
- Exceptions
-
Definition at line 445 of file Imap.php.
requestAndResponse($command, $tokens=array(), $dontParse=false)
◆ logout()
logout of imap server
- Returns
- bool success
Definition at line 455 of file Imap.php.
458 if ($this->_socket) {
464 fclose($this->_socket);
465 $this->_socket =
null;
requestAndResponse($command, $tokens=array(), $dontParse=false)
◆ noop()
send noop
- Returns
- bool success
Definition at line 808 of file Imap.php.
requestAndResponse($command, $tokens=array(), $dontParse=false)
◆ readLine()
readLine |
( |
& |
$tokens = array() , |
|
|
|
$wantedTag = '*' , |
|
|
|
$dontParse = false |
|
) |
| |
read a response "line" (could also be more than one real line if response has {..}<NL>) and do a simple decode
- Parameters
-
array | string | $tokens | decoded tokens are returned by reference, if $dontParse is true the unparsed line is returned here |
string | $wantedTag | check for this tag for response code. Default '*' is continuation tag. |
bool | $dontParse | if true only the unparsed line is returned $tokens |
- Returns
- bool if returned tag matches wanted tag
- Exceptions
-
Definition at line 284 of file Imap.php.
294 return $tag == $wantedTag;
◆ readResponse()
readResponse |
( |
|
$tag, |
|
|
|
$dontParse = false |
|
) |
| |
read all lines of response until given tag is found (last line of response)
- Parameters
-
string | $tag | the tag of your request |
string | array | $filter | you can filter the response so you get only the given response lines |
bool | $dontParse | if true every line is returned unparsed instead of the decoded tokens |
- Returns
- null|bool|array tokens if success, false if error, null if bad request
- Exceptions
-
Definition at line 308 of file Imap.php.
321 return $lines ? $lines :
true;
322 }
else if (
$tokens[0] ==
'NO'){
readLine(&$tokens=array(), $wantedTag=' *', $dontParse=false)
◆ rename()
rename an existing folder
- Parameters
-
string | $old | old name |
string | $new | new name |
- Returns
- bool success
Definition at line 776 of file Imap.php.
requestAndResponse($command, $tokens=array(), $dontParse=false)
◆ requestAndResponse()
requestAndResponse |
( |
|
$command, |
|
|
|
$tokens = array() , |
|
|
|
$dontParse = false |
|
) |
| |
send a request and get response at once
- Parameters
-
string | $command | command as in sendRequest() |
array | $tokens | parameters as in sendRequest() |
bool | $dontParse | if true unparsed lines are returned instead of tokens |
- Returns
- mixed response as in readResponse()
- Exceptions
-
Definition at line 386 of file Imap.php.
readResponse($tag, $dontParse=false)
sendRequest($command, $tokens=array(), &$tag=null)
◆ 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.
Definition at line 823 of file Imap.php.
831 if ($ids[0] ==
'SEARCH') {
requestAndResponse($command, $tokens=array(), $dontParse=false)
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
◆ select()
change folder
- Parameters
-
string | $box | change to this folder |
- Returns
- bool|array see examineOrselect()
- Exceptions
-
Definition at line 539 of file Imap.php.
examineOrSelect($command='EXAMINE', $box='INBOX')
◆ sendRequest()
sendRequest |
( |
|
$command, |
|
|
|
$tokens = array() , |
|
|
& |
$tag = null |
|
) |
| |
send a request
- Parameters
-
string | $command | your request command |
array | $tokens | additional parameters to command, use escapeString() to prepare |
string | $tag | provide a tag otherwise an autogenerated is returned |
- Returns
- null
- Exceptions
-
- See also
- Zend_Mail_Protocol_Exception
-
Zend_Mail_Protocol_Exception
-
Zend_Mail_Protocol_Exception
Definition at line 337 of file Imap.php.
344 $line = $tag .
' ' . $command;
348 if (@fputs($this->_socket, $line .
' ' .
$token[0] .
"\r\n") ===
false) {
352 #require_once 'Zend/Mail/Protocol/Exception.php'; 359 #require_once 'Zend/Mail/Protocol/Exception.php'; 368 if (@fputs($this->_socket, $line .
"\r\n") ===
false) {
372 #require_once 'Zend/Mail/Protocol/Exception.php';
◆ store()
store |
( |
array |
$flags, |
|
|
|
$from, |
|
|
|
$to = null , |
|
|
|
$mode = null , |
|
|
|
$silent = true |
|
) |
| |
set flags
- Parameters
-
array | $flags | flags to set, add or remove - see $mode |
int | $from | message for items or start message if $to !== null |
int | null | $to | if null only one message ($from) is fetched, else it's the last message, INF means last message avaible |
string | null | $mode | '+' to add flags, '-' to remove flags, everything else sets the flags as given |
bool | $silent | if false the return values are the new flags for the wanted messages |
- Returns
- bool|array new flags if $silent is false, else true or false depending on success
- Exceptions
-
Definition at line 680 of file Imap.php.
693 $set .=
':' . ($to == INF ?
'*' : (int)$to);
requestAndResponse($command, $tokens=array(), $dontParse=false)
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
◆ $_socket
◆ $_tagCount
◆ TIMEOUT_CONNECTION
const TIMEOUT_CONNECTION = 30 |
Default timeout in seconds for initiating session
Definition at line 36 of file Imap.php.
The documentation for this class was generated from the following file:
- vendor/magento/zendframework1/library/Zend/Mail/Protocol/Imap.php