本文整理匯總了PHP中InboundEmail::getMailboxes方法的典型用法代碼示例。如果您正苦於以下問題:PHP InboundEmail::getMailboxes方法的具體用法?PHP InboundEmail::getMailboxes怎麽用?PHP InboundEmail::getMailboxes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類InboundEmail
的用法示例。
在下文中一共展示了InboundEmail::getMailboxes方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: search
/**
* Searches IMAP (and POP3?) accounts/folders for emails with qualifying criteria
*/
function search($ieId, $subject = '', $from = '', $to = '', $body = '', $dateFrom = '', $dateTo = '')
{
global $current_user;
global $app_strings;
global $timedate;
$beans = array();
$bean = new InboundEmail();
$bean->retrieve($ieId);
$beans[] = $bean;
//$beans = $this->retrieveAllByGroupId($current_user->id, true);
$subject = urldecode($subject);
$criteria = "";
$criteria .= !empty($subject) ? 'SUBJECT ' . from_html($subject) . '' : "";
$criteria .= !empty($from) ? ' FROM "' . $from . '"' : "";
$criteria .= !empty($to) ? ' FROM "' . $to . '"' : "";
$criteria .= !empty($body) ? ' TEXT "' . $body . '"' : "";
$criteria .= !empty($dateFrom) ? ' SINCE "' . $timedate->fromString($dateFrom)->format('d-M-Y') . '"' : "";
$criteria .= !empty($dateTo) ? ' BEFORE "' . $timedate->fromString($dateTo)->format('d-M-Y') . '"' : "";
//$criteria .= (!empty($from)) ? ' FROM "'.$from.'"' : "";
$showFolders = unserialize(base64_decode($current_user->getPreference('showFolders', 'Emails')));
$out = array();
foreach ($beans as $bean) {
if (!in_array($bean->id, $showFolders)) {
continue;
}
$GLOBALS['log']->info("*** INBOUNDEMAIL: searching [ {$bean->name} ] for [ {$subject}{$from}{$to}{$body}{$dateFrom}{$dateTo} ]");
$group = !$bean->is_personal ? 'group.' : '';
$bean->connectMailServer();
$mailboxes = $bean->getMailboxes(true);
if (!in_array('INBOX', $mailboxes)) {
$mailboxes[] = 'INBOX';
}
$totalHits = 0;
foreach ($mailboxes as $mbox) {
$bean->mailbox = $mbox;
$searchOverviews = array();
if ($bean->protocol == 'pop3') {
$pop3Criteria = "SELECT * FROM email_cache WHERE ie_id = '{$bean->id}' AND mbox = '{$mbox}'";
$pop3Criteria .= !empty($subject) ? ' AND subject like "%' . $bean->db->quote($subject) . '%"' : "";
$pop3Criteria .= !empty($from) ? ' AND fromaddr like "%' . $from . '%"' : "";
$pop3Criteria .= !empty($to) ? ' AND toaddr like "%' . $to . '%"' : "";
$pop3Criteria .= !empty($dateFrom) ? ' AND senddate > "' . $dateFrom . '"' : "";
$pop3Criteria .= !empty($dateTo) ? ' AND senddate < "' . $dateTo . '"' : "";
$GLOBALS['log']->info("*** INBOUNDEMAIL: searching [ {$mbox} ] using criteria [ {$pop3Criteria} ]");
$r = $bean->db->query($pop3Criteria);
while ($a = $bean->db->fetchByAssoc($r)) {
$overview = new Overview();
foreach ($a as $k => $v) {
$k = strtolower($k);
switch ($k) {
case "imap_uid":
$overview->imap_uid = $v;
$overview->uid = $a['message_id'];
break;
case "toaddr":
$overview->to = from_html($v);
break;
case "fromaddr":
$overview->from = from_html($v);
break;
case "mailsize":
$overview->size = $v;
break;
case "senddate":
$overview->date = $timedate->fromString($v)->format('r');
break;
default:
$overview->{$k} = from_html($v);
break;
}
// sqitch
}
// foreach
$searchOverviews[] = $overview;
}
// while
} else {
$bean->connectMailServer();
$searchResult = imap_search($bean->conn, $criteria, SE_UID);
if (!empty($searchResult)) {
$searchOverviews = imap_fetch_overview($bean->conn, implode(',', $searchResult), FT_UID);
}
// if
}
// else
$numHits = count($searchOverviews);
if ($numHits > 0) {
$totalHits = $totalHits + $numHits;
$ret = $bean->sortFetchedOverview($searchOverviews, 'date', 'desc', true);
$mbox = "{$bean->id}.SEARCH";
$out = array_merge($out, $bean->displayFetchedSortedListXML($ret, $mbox, false));
}
}
}
$metadata = array();
$metadata['mbox'] = $app_strings['LBL_EMAIL_SEARCH_RESULTS_TITLE'];
$metadata['ieId'] = $this->id;
//.........這裏部分代碼省略.........
示例2: testgetMailboxes
public function testgetMailboxes()
{
$inboundEmail = new InboundEmail();
$inboundEmail->mailboxarray = array('INBOX.TRASH', 'OUTBOX.TRASH');
$expected = array('INBOX' => array('TRASH' => 'TRASH'), 'OUTBOX' => array('TRASH' => 'TRASH'));
//test with justRaw default/false
$result = $inboundEmail->getMailboxes();
$this->assertEquals($expected, $result);
//test with justRaw true
$result = $inboundEmail->getMailboxes(true);
$this->assertEquals($inboundEmail->mailboxarray, $result);
}