Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added move and delete function to message + expunge function #17

Merged
merged 1 commit into from
Sep 28, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Ddeboer/Imap/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
12 changes: 12 additions & 0 deletions src/Ddeboer/Imap/Mailbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
21 changes: 21 additions & 0 deletions src/Ddeboer/Imap/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}