clean.inc 735 B

12345678910111213141516171819202122232425
  1. <?php
  2. include_once(dirname(__FILE__) . '/imap_include.inc');
  3. $imap_stream = imap_open($default_mailbox, $username, $password);
  4. // delete all msgs in default mailbox, i.e INBOX
  5. $check = imap_check($imap_stream);
  6. for ($i = 1; $i <= $check->Nmsgs; $i++) {
  7. imap_delete($imap_stream, $i);
  8. }
  9. $mailboxes = imap_getmailboxes($imap_stream, $server, '*');
  10. foreach($mailboxes as $value) {
  11. // Only delete mailboxes with our prefix
  12. if (preg_match('/\{.*?\}INBOX\.(.+)/', $value->name, $match) == 1) {
  13. if (strlen($match[1]) >= strlen($mailbox_prefix)
  14. && substr_compare($match[1], $mailbox_prefix, 0, strlen($mailbox_prefix)) == 0) {
  15. imap_deletemailbox($imap_stream, $value->name);
  16. }
  17. }
  18. }
  19. imap_close($imap_stream, CL_EXPUNGE);
  20. ?>