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

Email reading issue sometimes its work and sometimes not work properly

Open AlpeshKatariya opened this issue 3 years ago • 1 comments

Describe the bug Email reading issue sometimes its work and sometimes not work properly.

Used config 'accounts' => [

    'default' => [// account identifier
        'host'  => env('IMAP_HOST', 'localhost'),
        'port'  => env('IMAP_PORT', 993),
        'protocol'  => env('IMAP_PROTOCOL', 'imap'), //might also use imap, [pop3 or nntp (untested)]
        'encryption'    => env('IMAP_ENCRYPTION', 'ssl'), // Supported: false, 'ssl', 'tls', 'notls', 'starttls'
        'validate_cert' => env('IMAP_VALIDATE_CERT', true),
        'username' => env('IMAP_USERNAME', '[email protected]'),
        'password' => env('IMAP_PASSWORD', ''),
        'authentication' => env('IMAP_AUTHENTICATION', null),
        'proxy' => [
            'socket' => null,
            'request_fulluri' => false,
            'username' => null,
            'password' => null,
        ]
    ],

]

Code to Reproduce The troubling code section which produces the reported bug. public function handle() { if (is_array($this->account)) { $client = ClientFacade::make($this->account); } else { $client = ClientFacade::account($this->account); }

    try {
        $client->connect();
    } catch (ConnectionFailedException $e) {
        Log::error($e->getMessage());
        return 1;
    }

    /** @var Folder $folder */
    try {
        $folder = $client->getFolder($this->folder_name);
    } catch (ConnectionFailedException $e) {
        Log::error($e->getMessage());
        return 1;
    } catch (FolderFetchingException $e) {
        Log::error($e->getMessage());
        return 1;
    }

    try {
        $folder->idle(function ($message) {
            $this->onNewMessage($message);

            if ($message->move('INBOX.read') == true) {
                Log::info('Message has ben moved');
            } else {
                Log::info('Message could not be moved');
            }
        });
    } catch (\Exception $e) {
        Log::error($e->getMessage());
        return 1;
    }

    return 0;
}

Expected behavior Email reading issue.

Screenshots

Desktop / Server (please complete the following information):

  • OS: [Window]
  • PHP: [7.4]
  • Version [v2.3.1]
  • Provider [e.g. Gmail]

Additional context

AlpeshKatariya avatar Jun 13 '22 07:06 AlpeshKatariya

Hi @AlpeshKatariya , thanks for your report. I believe to have determined and fixed the issue with the latest release. Please update to >= v4.0.0 and try again.

Best regards & happy coding,

Webklex avatar Aug 19 '22 19:08 Webklex