Webklex / laravel-imap

Laravel IMAP is an easy way to integrate both the native php-imap module and an extended custom imap protocol into your Laravel app.
https://www.php-imap.com
MIT License
617 stars 177 forks source link

Deleting messages in a thread #480

Open FR31NDSDEV opened 10 months ago

FR31NDSDEV commented 10 months ago

Say there's a thread:

Message 1 Message 2 Message 3 Message 4

For example if Message 3 is deleted / moved to trash, Message 4 is also deleted. Same for message 2, it would be understandable if this occurred in the parent message which is Message 1, but it's also the case for any message in the thread.

Here's what I tried doing:

public function deleteEmail($folder, $uid, $nextUid)
    {
        $message = $this->findMessageByUid($folder, $uid);
        $nextMessage = $this->findMessageByUid($folder, $nextUid);
        if($nextMessage){
        $nextMessage->in_reply_to = $message->in_reply_to;
         }

        $message->move('INBOX.Trash');
    }

Although this solution would cause a lot of problems when trying to restore the deleted email, but I didn't find any other way. If anyone has an insight on this, please enlighten me.

Edit: I also tried using $message->delete($expunge = true) but it produced the same output.