laravel-imap icon indicating copy to clipboard operation
laravel-imap copied to clipboard

Deleting messages in a thread

Open FR31NDSDEV opened this issue 2 years ago • 1 comments

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.

FR31NDSDEV avatar Aug 15 '23 02:08 FR31NDSDEV

hey are these methods your custom or inbuilt fnctions to getMessage

$message = $this->findMessageByUid($folder, $uid); $nextMessage = $this->findMessageByUid($folder, $nextUid);

im new to this Weblex and i cant get message

` public function moveToTrash($emailId) { $email = Email::find($emailId);

    if ($email) {
        $client = Client::account('default');
        $client->connect();

        $folder = $client->getFolder('INBOX');
        $message = $folder->getMessage($email->message_id);
        $message->move('Trash');

        $client->disconnect();

        $email->delete(); // Soft delete
    }
}

`

error: Undefined method 'getMessage'.

so is there any way to get message

sameededitz avatar Sep 13 '24 05:09 sameededitz

Hi @FR31NDSDEV , many thanks for your report. Unfortunately I'm unable to reproduce the issue at this point. Perhaps you are using an outdated version of webklex/php-imap? If that's the case, please update it to the latest version. This laravel-wrapper fully relies on the functionality of webklex/php-imap.

If the issue still persists, please head over here (https://github.com/Webklex/php-imap/issues/new?template=bug_report.md) and create a new issue. If you do, please provide as much information as possible (such as a failing test case or anything else which could help to reproduce the issue).

Best regards & happy coding,

Webklex avatar Jan 19 '25 17:01 Webklex