note 80251 added to function.imap-getmailboxes

From: Date: Sun, 06 Jan 2008 08:49:17 +0000
Subject: note 80251 added to function.imap-getmailboxes
Groups: php.notes 
Request: Send a blank email to php-notes+get-134843@lists.php.net to get a copy of this message
i think it will save someones time to get mailbox list and their attributes within a formatted array /********** Function ******************/ function getAttributesFlagArray($p_attributes){ $attrs[LATT_HASNOCHILDREN]='false'; $attrs[LATT_HASCHILDREN]='false'; $attrs[LATT_REFERRAL]='false'; $attrs[LATT_UNMARKED]='false'; $attrs[LATT_MARKED]='false'; $attrs[LATT_NOSELECT]='false'; $attrs[LATT_NOINFERIORS]='false'; $attrsX=$attrs; foreach($attrs as $attrkey=>$attrval){ if ($p_attributes & $attrkey){ $attrsX[$attrkey]='true'; $p_attributes-=$attrkey; } } return $attrsX; } /*********** Usages *****************/ $mboxconnstr='{imap.gmail.com:993/imap/ssl}'; // $mboxconnstr='{mail.bdways.com:143/imap/novalidate-cert}'; $mbox = imap_open($mboxconnstr, $username, $password, OP_HALFOPEN) or die("can't connect: " . imap_last_error()); echo "<h1>Mailboxes</h1>\n"; $folders = imap_getmailboxes($mbox, $mboxconnstr, "*"); if(is_array($folders)){ foreach($folders as $fkey=>$folder){ $mapname = str_replace($mboxconnstr, "", imap_utf7_decode($folder->name)); if($mapname[0] != ".") { //$attrs[LATT_]=': NO'; $list_folders[$fkey]['name'] = $folder->name; $list_folders[$fkey]['nameX'] = $mapname; $list_folders[$fkey]['delimiter'] = $folder->delimiter; $list_folders[$fkey]['attributes'] = $folder->attributes; $list_folders[$fkey]['attr_values'] = getAttributesFlagArray($folder->attributes); } } }else echo "Call failed<br />\n"; echo('<pre>'); print_r($list_folders); echo('</pre>'); thanks to Mohamed Abbas mabbas_xyz at yahoo dot com for his attributes findings using imap... ---- Server IP: 69.147.83.197 Probable Submitter: 202.59.136.8 ---- Manual Page -- http://www.php.net/manual/en/function.imap-getmailboxes.php Edit -- https://master.php.net/note/edit/80251 Del: integrated -- https://master.php.net/note/delete/80251/integrated Del: useless -- https://master.php.net/note/delete/80251/useless Del: bad code -- https://master.php.net/note/delete/80251/bad+code Del: spam -- https://master.php.net/note/delete/80251/spam Del: non-english -- https://master.php.net/note/delete/80251/non-english Del: in docs -- https://master.php.net/note/delete/80251/in+docs Del: other reasons-- https://master.php.net/note/delete/80251 Reject -- https://master.php.net/note/reject/80251 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#134843) next »