diff --git a/src/Ddeboer/Imap/Connection.php b/src/Ddeboer/Imap/Connection.php index b62d84d3..7af2275d 100644 --- a/src/Ddeboer/Imap/Connection.php +++ b/src/Ddeboer/Imap/Connection.php @@ -64,4 +64,15 @@ protected function getMailboxNames() return $this->mailboxNames; } + + /** + * Close connection + * + * @param int $flag + * @return bool + */ + public function close($flag = 0) + { + return \imap_close($this->resource, $flag); + } } \ No newline at end of file diff --git a/src/Ddeboer/Imap/Mailbox.php b/src/Ddeboer/Imap/Mailbox.php index d24c0cde..2f8a8254 100644 --- a/src/Ddeboer/Imap/Mailbox.php +++ b/src/Ddeboer/Imap/Mailbox.php @@ -94,6 +94,18 @@ public function getIterator() return $this->getMessages(); } + /** + * Delete all messages marked for deletion + * + * @return boolean + */ + public function expunge() + { + $this->init(); + + return \imap_expunge($this->stream); + } + /** * If connection is not currently in this mailbox, switch it to this mailbox */ diff --git a/src/Ddeboer/Imap/Message.php b/src/Ddeboer/Imap/Message.php index dec51f4c..ad2df48d 100644 --- a/src/Ddeboer/Imap/Message.php +++ b/src/Ddeboer/Imap/Message.php @@ -218,4 +218,25 @@ protected function loadStructure() $structure = \imap_fetchstructure($this->stream, $this->messageNumber); $this->parseStructure($structure); } + + /** + * Delete message + */ + public function delete() + { + // 'deleted' header changed, force to reload headers, would be better to set deleted flag to true on header + $this->headers = null; + + return \imap_delete($this->stream, $this->messageNumber); + } + + /** + * Move message to another mailbox + * @param Mailbox $mailbox + * @return bool + */ + public function move(Mailbox $mailbox) + { + return \imap_mail_move($this->stream, $this->messageNumber, $mailbox->getName()); + } } \ No newline at end of file