Back to index

php5  5.3.10
clean.inc
Go to the documentation of this file.
00001 <?php
00002 include_once(dirname(__FILE__) . '/imap_include.inc');
00003 
00004 $imap_stream = imap_open($default_mailbox, $username, $password);
00005 
00006 // delete all msgs in default mailbox, i.e INBOX
00007 $check = imap_check($imap_stream);
00008 for ($i = 1; $i <= $check->Nmsgs; $i++) {
00009        imap_delete($imap_stream, $i); 
00010 }
00011 
00012 $mailboxes = imap_getmailboxes($imap_stream, $server, '*');
00013 
00014 foreach($mailboxes as $value) {
00015        // Only delete mailboxes with our prefix
00016        if (preg_match('/\{.*?\}INBOX\.(.+)/', $value->name, $match) == 1) {
00017               if (strlen($match[1]) >= strlen($mailbox_prefix) 
00018               && substr_compare($match[1], $mailbox_prefix, 0, strlen($mailbox_prefix)) == 0) {
00019                      imap_deletemailbox($imap_stream, $value->name);
00020               }
00021        }      
00022 }
00023 
00024 imap_close($imap_stream, CL_EXPUNGE); 
00025 ?>