Здесь функция
открытая функция indexAllMails ($ startIndex = 1)
{
$this->_imap = new Zend_Mail_Protocol_Imap('imap.gmail.com', '993', true);
$authenticateParams = array('XOAUTH', $initClientRequestEncoded);
$this->_imap->requestAndResponse('AUTHENTICATE', $authenticateParams);
//Create the mail storage Object
$this->_storage = new Zend_Mail_Storage_Imap_Wrapper($this->_imap);
//Select Folder
$this->_storage->selectFolder("[Gmail]/All Mail");
$numMessagesTotal = $this->_storage->countMessages();
if($numMessagesTotal == 0 ) return true;
for($i=$startIndex;$i<=$numMessagesTotal;$i++)
{
try {
$uniqueId = $this->_storage->getUniqueId($i);
$message = $this->_storage->getMessage($i);
}
catch(Exception $ex)
{
log("Error getting Unique id",'index');
log($ex->getMessage(),'index');
log($ex->getTraceAsString(),'index');
if($ex->getMessage() == 'cannot read - connection closed?')
{
//Timeout :(
return true;
}
else
continue;
}
$from = $message->from;
echo $from;
}
}