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

Can not delete message; get exception also it is deleted from INBOX #512

Open
napengam opened this issue Aug 31, 2024 · 3 comments
Open

Comments

@napengam
Copy link

Deleting one email from gmail INBOX throws exception, but it is actualy deleted from INBOX

´´´
[31-Aug-2024 20:38:39 Europe/Berlin] PHP Fatal error: Uncaught Webklex\PHPIMAP\Exceptions\ResponseException: Command failed to process:
Causes:
- Empty response
Commands send:
TAG11 UID FETCH 842 (FLAGS)\r\n
Responses received:
TAG11 OK Success\r\n
Error occurred in F:\xampp-htdocs\projectCore\vendor\webklex\php-imap\src\Exceptions\ResponseException.php:53
Stack trace:
#0 F:\xampp-htdocs\projectCore\vendor\webklex\php-imap\src\Connection\Protocols\Response.php(318): Webklex\PHPIMAP\Exceptions\ResponseException::make(Object(Webklex\PHPIMAP\Connection\Protocols\Response), true)
#1 F:\xampp-htdocs\projectCore\vendor\webklex\php-imap\src\Connection\Protocols\Response.php(308): Webklex\PHPIMAP\Connection\Protocols\Response->validate()
#2 F:\xampp-htdocs\projectCore\vendor\webklex\php-imap\src\Message.php(585): Webklex\PHPIMAP\Connection\Protocols\Response->validatedData()
#3 F:\xampp-htdocs\projectCore\vendor\webklex\php-imap\src\Message.php(1254): Webklex\PHPIMAP\Message->parseFlags()
#4 F:\xampp-htdocs\projectCore\vendor\webklex\php-imap\src\Message.php(1194): Webklex\PHPIMAP\Message->setFlag('\Deleted')
#5 F:\xampp-htdocs\projectCore\test\klex.php(62): Webklex\PHPIMAP\Message->delete(false)
#6 {main}
thrown in F:\xampp-htdocs\projectCore\vendor\webklex\php-imap\src\Exceptions\ResponseException.php on line 53
´´´

@IulianMoldovanu
Copy link

IulianMoldovanu commented Sep 13, 2024

I encountered the same issue and resolved it by using $message->move('[Gmail]/Trash') instead of $message->delete().
and delete() method will apply only for trash folder
if ($folder->path === '[Gmail]/Trash') { return $message->delete(); }

@napengam
Copy link
Author

napengam commented Sep 13, 2024 via email

@sertancayci-jf
Copy link

sertancayci-jf commented Jan 2, 2025

@napengam i tried try catch but still take belowed error. Also i tried $message->delete(); , $message->delete(true) or $message->delete($expunge = true) . I always take same error Any help?

php: 8.3
php-imap: 5.5.0

Command failed to process:
Causes:

  • Empty response

` $foundedMessage = null;
foreach($messages as $message){
echo "Message: " . PHP_EOL;
echo "Subject: " . $message->getSubject() . PHP_EOL;
echo "UID: " . $message->getUid() . PHP_EOL;
echo "Timestamp: " . $message->getDate() . PHP_EOL;

        if (trim($message->getSubject()) === trim($subject)) {
            $foundedMessage = $message;
            echo "Email found." . PHP_EOL;
            try {
                $message->setFlag("Deleted");
                echo "Email marked as deleted." . PHP_EOL;
            } catch (\Exception $e) {
                // Log the error or handle it appropriately
                echo "Failed to delete message: " . $e->getMessage();
            }
            break;
        }

    }`
    
    
    <<  FLAGS (\Seen))

<< * 1 FETCH (UID 12345 FLAGS (\Seen))
<< TAG7 OK Success

TAG8 UID STORE 12345:12345 -FLAGS.SILENT (\Seen)

<< * 1 FETCH (UID 12345 FLAGS ())
<< TAG8 OK Success

TAG9 UID FETCH 12345 (FLAGS)

<< * 1 FETCH (UID 12345 FLAGS ())
<< TAG9 OK Success
Message:
Subject: "subject"
UID: 12345
Timestamp: 2025-01-02 09:36:23
Email found.

TAG10 UID STORE 12345:12345 +FLAGS.SILENT (\Deleted)

<< * 1 EXPUNGE
<< * 0 EXISTS
<< TAG10 OK Success

TAG11 UID FETCH 12345 (FLAGS)

<< TAG11 OK Success
Failed to delete message: Command failed to process:
Causes:
- Empty response
Commands send:
TAG11 UID FETCH 12345 (FLAGS)\r\n
Responses received:
TAG11 OK Success\r\n
Error occurred>> TAG12 EXPUNGE

<< TAG12 OK Success

TAG13 LOGOUT

<< * BYE LOGOUT Requested
<< TAG13 OK 73 good day (Success)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants