add message actions feature

This commit is contained in:
Clivern 2017-09-02 15:33:59 +02:00
parent 0640f48093
commit 900e78467b
4 changed files with 39 additions and 3 deletions

View file

@ -40,6 +40,13 @@ $connection = new Connection(
$connection->connect();
```
After end of everything, you should close connection
```php
$connection->disconnect();
```
#### Connection Options
```php
@ -243,6 +250,15 @@ foreach ($attachments as $attachment) {
}
```
To do actions on message like delete or undelete
```php
$message->action()->delete();
$message->action()->undelete();
// and don't forget to run the following to delete all messages marked for deletion
$mailbox->expunge();
```
Misc
====

View file

@ -266,7 +266,7 @@ class Connection
* @param integer $flag
* @return boolean
*/
public function disconnect($flag = 0)
public function disconnect($flag = \CL_EXPUNGE)
{
if( !is_null($this->stream) && imap_ping($this->stream) ){
if( imap_close($this->stream, $flag) ){

View file

@ -55,4 +55,24 @@ class Action
return $this;
}
/**
* Delete Message
*
* @return boolean
*/
public function delete()
{
return (boolean) imap_delete($this->connection->getStream(), $this->message_uid, \FT_UID);
}
/**
* Undelete Message
*
* @return boolean
*/
public function undelete()
{
return (boolean) imap_undelete($this->connection->getStream(), $this->message_uid, \FT_UID);
}
}

View file

@ -130,12 +130,12 @@ class MailBox
/**
* Delete all messages marked for deletion
*
* @return Mailbox
* @return boolean
*/
public function expunge()
{
$this->connection->survive($this->folder);
imap_expunge($this->connection->getStream());
return (boolean) imap_expunge($this->connection->getStream());
}
/**