YetiForceCompany / YetiForceCRM

Our team created for you one of the most innovative CRM systems that supports mainly business processes and allows for customization according to your needs. Be ahead of your competition and implement YetiForce!
https://yetiforce.com
Other
1.71k stars 741 forks source link

[bug] Mail Scanner fails if not mails to import #17535

Open diderich opened 1 month ago

diderich commented 1 month ago

🐞 bug report

⁉️ Describe the bug

PHPIMAP throws an exception stating Empty response when running the cron job to import e-mails (LBL_MAIL_SCANNER_ACTION).

2024-07-08 08:25:02 | LBL_MAIL_SCANNER_ACTION - Start task
Webklex\PHPIMAP\Exceptions\ResponseException: Command failed to process:
Causes:
    - Empty response
Error occurred in /opt/crm7/vendor/webklex/php-imap/src/Exceptions/ResponseException.php:53
Stack trace:
#0 /opt/crm7/vendor/webklex/php-imap/src/Connection/Protocols/Response.php(318): Webklex\PHPIMAP\Exceptions\ResponseException::make()
#1 /opt/crm7/vendor/webklex/php-imap/src/Connection/Protocols/Response.php(308): Webklex\PHPIMAP\Connection\Protocols\Response->validate()
#2 /opt/crm7/vendor/webklex/php-imap/src/Query/Query.php(525): Webklex\PHPIMAP\Connection\Protocols\Response->validatedData()
#3 /opt/crm7/vendor/webklex/php-imap/src/Query/Query.php(573): Webklex\PHPIMAP\Query\Query->filter()
#4 /opt/crm7/app/Mail/Connections/Imap.php(163): Webklex\PHPIMAP\Query\Query->getByUidGreater()
#5 /opt/crm7/app/Mail/Scanner.php(126): App\Mail\Connections\Imap->getMessagesGreaterThanUid()
#6 /opt/crm7/modules/OSSMailScanner/crons/Scann.php(46): App\Mail\Scanner->run()
#7 /opt/crm7/cron.php(100): OSSMailScanner_Scann_Cron->process()
#8 {main}

πŸ”₯ How to trigger the error

Steps to reproduce the behavior:

  1. Run php cron.php
  2. See error

πŸ‘Ž Actual Behavior

The cron run raises an exception (as show above).

πŸ‘ Expected Behavior

The cron run completes successfully.

πŸ‘· Testing

πŸ“· Screenshot of configuration

ConfReport

πŸ“ PHP/Apache/Nginx/Browser/CRM Logs

See above for log message in cache error file.

🌍 Your Environment

Environment Version / Name
YetiForce 7.0.1
Web server (name and version) apache2 2.4.58
PHP 8.3.9
Browser (name and version) n/a
Operating System (name and version) Linux
Database (name and version) MariaDB 11.4.2
Service Pack version

❓ Additional context

N/A

❗️ Inform the community if you solve the problem

diderich commented 1 month ago

It seems that replacing

public function getMessagesGreaterThanUid(string $folderName, int $uid, int $limit)
{
    return $this->getFolderByName($folderName)->query()->limit($limit)->getByUidGreater($uid);
}

in app/Mail/Connections/Imap.php

by

public function getMessagesGreaterThanUid(string $folderName, int $uid, int $limit)
{
    try {
       return $this->getFolderByName($folderName)->query()->limit($limit)->getByUidGreater($uid);
    }
    catch(\Exception $err) {
      return new \Webklex\PHPIMAP\Support\MessageCollection();
    }
}

solves the problem, but I don't know whether that is the right way of addressing the problem.

joice-martins commented 1 month ago

Having problems with the import here as well. Any chance you could help with my issue #17565? :(