add message actions feature
This commit is contained in:
parent
0640f48093
commit
900e78467b
16
README.md
16
README.md
|
@ -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
|
||||
====
|
||||
|
|
|
@ -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) ){
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue