public function purge() {
        // delete trash and spam
        if ($this->folder==$this->getTrash() || strtolower($this->folder)=="spam") {
            if (imap_delete($this->imap,'1:*') === false) {
                return false;
            }
            return imap_expunge($this->imap);

            // move others to trash
        } else {
            if (imap_mail_move($this->imap,'1:*', $this->getTrash()) == false) {
                return false;
            }
            return imap_expunge($this->imap);
        }
    }
public function purge() {
        // delete trash and spam
        if ($this->folder==$this->getTrash() || strtolower($this->folder)=="spam") {
            if (imap_delete($this->imap,'1:*') === false) {
                return false;
            }
            return imap_expunge($this->imap);

            // move others to trash
        } else {
            if (imap_mail_move($this->imap,'1:*', $this->getTrash()) == false) {
                return false;
            }
            return imap_expunge($this->imap);
        }
    }
public function purge ( ) { // delete trash and spam if ( $ this -> folder == $ this -> getTrash ( ) || strtolower ( $ this -> folder ) == "spam" ) { if ( imap_delete ( $ this -> imap , '1:*' ) === false ) { return false ; } return imap_expunge ( $ this -> imap ) ; // move others to trash } else { if ( imap_mail_move ( $ this -> imap , '1:*' , $ this -> getTrash ( ) ) == false ) { return false ; } return imap_expunge ( $ this -> imap ) ; } }
Clean up trash and spam folder

@return bool success or not
Clean up trash and spam folder