Exemple #1
0
 function testIMAP()
 {
     $conn = new Net_IMAP(HOST, PORT);
     // we need to login for getting the delimiter
     $conn->login(USER, PASS);
     if (PEAR::isError($this->delimiter = $conn->getHierarchyDelimiter())) {
         $this->fail('Can not get hierarchy delimiter');
     }
     $conn->disconnect();
     $this->reservedFolders = array('INBOX', 'INBOX' . $this->delimiter . 'Trash');
 }
 function getImapFolders(MailAccount $account)
 {
     if ($account->getIncomingSsl()) {
         $imap = new Net_IMAP($ret, "ssl://" . $account->getServer(), $account->getIncomingSslPort());
     } else {
         $imap = new Net_IMAP($ret, "tcp://" . $account->getServer());
     }
     if (PEAR::isError($ret)) {
         //Logger::log($ret->getMessage());
         throw new Exception($ret->getMessage());
     }
     $ret = $imap->login($account->getEmail(), self::ENCRYPT_DECRYPT($account->getPassword()));
     if ($ret !== true || PEAR::isError($ret)) {
         //Logger::log($ret->getMessage());
         throw new Exception($ret->getMessage());
     }
     $result = array();
     if ($ret === true) {
         $mailboxes = $imap->getMailboxes('', 0, true);
         if (is_array($mailboxes)) {
             foreach ($mailboxes as $mbox) {
                 $select = true;
                 $attributes = array_var($mbox, 'ATTRIBUTES');
                 if (is_array($attributes)) {
                     foreach ($attributes as $att) {
                         if (strtolower($att) == "\\noselect") {
                             $select = false;
                         }
                         if (!$select) {
                             break;
                         }
                     }
                 }
                 $name = array_var($mbox, 'MAILBOX');
                 if ($select && isset($name)) {
                     $result[] = utf8_encode($name);
                 }
             }
         }
     }
     $imap->disconnect();
     return $result;
 }
 function disconnect()
 {
     parent::disconnect();
     $this->_isConnected = false;
 }
    #var_dump($nameSpace);
} else {
    print "<span style='color:red;'>not supported</span></h1>";
}
$elapsedTime = microtime(true) - $startTime;
print "<h1> {$elapsedTime} :: Checking for QUOTA support: ";
if ($imapClient->hasCapability('QUOTA')) {
    print "<span style='color:green;'>supported</span></h1>";
    $quota = $imapClient->getStorageQuotaRoot();
    print "parsed QUOTA info:<br>";
    var_dump($quota);
} else {
    print "<span style='color:red;'>not supported</span></h1>";
}
$elapsedTime = microtime(true) - $startTime;
print "<h1> {$elapsedTime} :: Checking for SORT support: ";
if ($imapClient->hasCapability('SORT')) {
    print "<span style='color:green;'>supported</span></h1>";
    $elapsedTime = microtime(true) - $startTime;
    print "<h2> {$elapsedTime} :: Sorting {$testFolder} by DATE:</h2>";
    $sortResult = $imapClient->sort('DATE');
    $elapsedTime = microtime(true) - $startTime;
    print "<h2> {$elapsedTime} :: Sorting {$testFolder} by SUBJECT:</h2>";
    $sortResult = $imapClient->sort('SUBJECT');
} else {
    print "<span style='color:red;'>not supported</span></h1>";
}
$elapsedTime = microtime(true) - $startTime;
print "<h1> {$elapsedTime} :: Logout</h1>";
$imapClient->disconnect();
print "</pre>";