/** * try to get a message from imap server (with complete body, attachments, etc) * */ public function testGetMessage() { $message = $this->_sendMessage(); // get complete message $message = $this->_json->getMessage($message['id']); // check $this->assertGreaterThan(0, preg_match('/aaaaaä/', $message['body'])); // delete message on imap server and check if correct exception is thrown when trying to get it $this->_imap->removeMessage($message['messageuid']); Tinebase_Core::getCache()->clean(); $this->setExpectedException('Felamimail_Exception_IMAPMessageNotFound'); $message = $this->_json->getMessage($message['id']); }
/** * try to get a message from imap server (with complete body, attachments, etc) * * @see 0006300: add unique message-id header to new messages (for message-id check) */ public function testGetMessage() { $message = $this->_sendMessage(); // get complete message $message = $this->_json->getMessage($message['id']); // check $this->assertTrue(isset($message['headers']) && $message['headers']['message-id']); $this->assertContains('@' . $this->_mailDomain, $message['headers']['message-id']); $this->assertGreaterThan(0, preg_match('/teste/', $message['body'])); // delete message on imap server and check if correct exception is thrown when trying to get it $this->_imap->removeMessage($message['messageuid']); // Tinebase_Core::getCache()->clean(); $this->setExpectedException('Tinebase_Exception_NotFound'); $message = $this->_json->getMessage($message['id']); }
/** * update folder quota (check if server supports QUOTA first) * * @param Felamimail_Model_Folder $_folder * @param Felamimail_Backend_ImapProxy $_imap */ protected function _updateFolderQuota(Felamimail_Model_Folder $_folder, Felamimail_Backend_ImapProxy $_imap) { // only do it for INBOX if ($_folder->localname !== 'INBOX') { return; } $account = Felamimail_Controller_Account::getInstance()->get($_folder->account_id); if (!$account->hasCapability('QUOTA')) { if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Account ' . $account->name . ' has no QUOTA capability'); } return; } if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Getting quota for INBOX ' . $_folder->getId()); } // get quota and save in folder $quota = $_imap->getQuota($_folder->localname); if (!empty($quota) && isset($quota['STORAGE'])) { $_folder->quota_usage = $quota['STORAGE']['usage']; $_folder->quota_limit = $quota['STORAGE']['limit']; } else { $_folder->quota_usage = 0; $_folder->quota_limit = 0; } if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($quota, TRUE)); } }
/** * add/clear flags on imap server * * @param array $_imapMessageUids * @param array $_flags * @param Felamimail_Backend_ImapProxy $_imapBackend * @throws Felamimail_Exception_IMAP */ protected function _updateFlagsOnImap($_imapMessageUids, $_flags, $_imapBackend, $_mode) { $flagsToChange = array_intersect($_flags, array_keys(self::$_allowedFlags)); if (empty($flagsToChange)) { return; } if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . $_mode . 'ing flags on IMAP server for ' . print_r($_imapMessageUids, TRUE) . ' messages:' . print_r($flagsToChange, TRUE)); } try { if ($_mode === 'add') { $_imapBackend->addFlags($_imapMessageUids, $flagsToChange); } else { if ($_mode === 'clear') { $_imapBackend->clearFlags($_imapMessageUids, $flagsToChange); } } } catch (Zend_Mail_Storage_Exception $zmse) { throw new Felamimail_Exception_IMAP($zmse->getMessage()); } }
/** * move messages on imap server * * @param array $_uids * @param string $_targetFolderName * @param Felamimail_Backend_ImapProxy $_imap * * @todo perhaps we should check the existance of the messages on the imap instead of catching the exceptions here */ protected function _moveBatchOfMessages($_uids, $_targetFolderName, Felamimail_Backend_ImapProxy $_imap) { if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Move ' . count($_uids) . ' messages to folder ' . $_targetFolderName . ' on imap server'); } try { $_imap->copyMessage($_uids, Felamimail_Model_Folder::encodeFolderName($_targetFolderName)); $_imap->addFlags($_uids, array(Zend_Mail_Storage::FLAG_DELETED)); } catch (Zend_Mail_Storage_Exception $zmse) { if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) { Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' ' . $zmse); } } catch (Felamimail_Exception_IMAP $fei) { if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) { Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' ' . $fei); } } }