PHP Manual: imap_close
imap_close
Parameters
imap_streamAn IMAP stream returned by imap_open().
flagIf set to CL_EXPUNGE, the function will silently expunge the mailbox before closing, removing all messages marked for deletion. You can achieve the same thing by using imap_expunge()