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

"Empty response" when delete is used on Google Accounts

Open fresent opened this issue 1 year ago • 1 comments

Describe the bug Running into issue with message "Empty response" when delete is used on Google (both free gmail and g-suite account).

Used config

$options = [
                    'options' => [
                        'soft_fail' => false,
                        'debug' => true,
                    ],
                ];
$connectionConfig = [
                    'host'          => -,
                    'port'          => 993,
                    'encryption'    => 'ssl',
                    'validate_cert' => true,
                    'fetch' => \Webklex\PHPIMAP\IMAP::FT_PEEK,
                    'sequence' => \Webklex\PHPIMAP\IMAP::ST_UID,
                    'fetch_flags' => true,
                    'soft_fail' => false,
                    'username'      => emailAddress,
                    'password'      => AppPasswordFromGmail,
                    'protocol'      => 'imap',
                    'timeout'       => 180,
                    'dispositions' => ['attachment', 'inline'],
                    'decoder' => [
                        'message' => 'utf-8', // mimeheader
                        'attachment' => 'utf-8' // mimeheader
                    ]
                ];

StackTrace

[2024-02-05 05:17:37] production.WARNING: array (
  'Email Attempted' => '[email protected]',
  'Error Message' => 'Command failed to process:
Causes:
        - Empty response
Commands send:
        TAG20 UID FETCH 2886 (FLAGS)\\r\\n
Responses received:
        TAG20 OK Success\\r\\n
Error occurred',
  'Error StackTrace' => '#0 /masked-home-location/application/vendor/webklex/php-imap/src/Connection/Protocols/Response.php(318): Webklex\\PHPIMAP\\Exceptions\\ResponseException::make()
#1 /masked-home-location/application/vendor/webklex/php-imap/src/Connection/Protocols/Response.php(308): Webklex\\PHPIMAP\\Connection\\Protocols\\Response->validate()
#2 /masked-home-location/application/vendor/webklex/php-imap/src/Message.php(585): Webklex\\PHPIMAP\\Connection\\Protocols\\Response->validatedData()
#3 /masked-home-location/application/vendor/webklex/php-imap/src/Message.php(1254): Webklex\\PHPIMAP\\Message->parseFlags()
#4 /masked-home-location/application/vendor/webklex/php-imap/src/Message.php(1194): Webklex\\PHPIMAP\\Message->setFlag()
#5 /masked-home-location/application/app/Application call: Webklex\\PHPIMAP\\Message->delete()
[2024-02-05 05:18:20] production.WARNING: array (
  'Email Attempted' => 'Google Workplace account',
  'Error Message' => 'Command failed to process:
Causes:
        - Empty response
Commands send:
        TAG23 UID FETCH 2632 (FLAGS)\\r\\n
Responses received:
        TAG23 OK Success\\r\\n
Error occurred',
  'Error StackTrace' => '#0 /masked-home-location/application/vendor/webklex/php-imap/src/Connection/Protocols/Response.php(318): Webklex\\PHPIMAP\\Exceptions\\ResponseException::make()
#1 /masked-home-location/application/vendor/webklex/php-imap/src/Connection/Protocols/Response.php(308): Webklex\\PHPIMAP\\Connection\\Protocols\\Response->validate()
#2 /masked-home-location/application/vendor/webklex/php-imap/src/Message.php(585): Webklex\\PHPIMAP\\Connection\\Protocols\\Response->validatedData()
#3 /masked-home-location/application/vendor/webklex/php-imap/src/Message.php(1254): Webklex\\PHPIMAP\\Message->parseFlags()
#4 /masked-home-location/application/vendor/webklex/php-imap/src/Message.php(1194): Webklex\\PHPIMAP\\Message->setFlag()
#5 /masked-home-location/application/app/Application call: Webklex\\PHPIMAP\\Message->delete()

Expected behavior Using delete on email should not be throwing error and just delete the message. Seems IMAP is returning correctly (with message OK Success) but library is still throwing error with Empty Response

Desktop / Server (please complete the following information):

  • OS: Ubuntu 22
  • PHP: 8.1
  • Version : 5.5.0
  • Provider : Gmail

fresent avatar Feb 05 '24 05:02 fresent

I'm seeing the same thing, using PHP-IMAP for the first time.

I don't understand the protocol enough to debug why this is happening, but can see a clear difference in the Response when parseFlags() is called when initially querying messages, compared to from within the setFlag() called inside delete():

On load: flags-on-load

delete() -> setFlag() -> parseFlags(): flags-after-set-delete

chrisminett avatar Oct 21 '24 11:10 chrisminett