YetiForceCompany / YetiForce

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
2 stars 3 forks source link

How to force mail scanner to stop after timeout #25

Open vslonska opened 1 month ago

vslonska commented 1 month ago

Hello, I quite often have a problem with the mail scanner, which goes on and on and on... even if the Cron is ok and running well, and the server configured as recommended. I have to manually stop it and to wait a few minutes for the cron to start it to get it work again. Capture d’écran du 2024-09-12 22-29-23

I would like to automatically stop it if it doesn't end after some time. Is it possible ?

Thank you, Regards,

garryatbrighton commented 1 month ago

Go to your database and fire: delete from vtiger_ossmails_logs where status = 1 limit 1;

I have set it in cron: /5 * /usr/bin/mysql -u[user] -p[password]< /var/www/html/mysql-commands/clearmailscanner.sql > /var/www/html/cache/logs/cronmysql.log 2>&1

clearmailscanner.sql: USE mydatabase; delete from vtiger_ossmails_logs where status = 1 limit 1;

rskrzypczak commented 1 month ago

@garryatbrighton This will not solve the problem in any way.

The problem in such cases is always the issue of parsing the email. The YF system cannot handle it for some reason. The problem is usually the attachments, headers or the email content itself. So I recommend activating the application logs and see what exactly is the problem.

By the way, if you are using version 6.5 or lower, I recommend updating to 7.0.x, because the entire mechanism of the email scanner has been thoroughly rebuilt and it will most likely reduce the number of errors in this area.

vslonska commented 1 month ago

Thank you for your answers. I use the last version of Yetiforce. Which logs should I activate?

I also activated the option in config/main.php to stop Cron after 1 hour if the task is not completed but it doesn't stop the email scanner.

Thank you, Regards,

rskrzypczak commented 1 month ago

Which logs should I activate?

config/Debug.php

public static $LOG_TO_FILE = true;
public static $LOG_LEVELS = ['error','warning'];
public static $LOG_TRACE_LEVEL = 9;

public static $DEBUG_CRON = true;

Logs will be registered in the following file: cache/logs/system.log and cache/logs/cron/*

vslonska commented 1 month ago

Hello, I have in te log file :

2024-09-23 22:13:10.323 [error][] - Mail Scanner - Account: 1, folder: INBOX, UID: 581, message: ERR_ILLEGAL_FIELD_VALUE||subject||OSSMailView||

Échec de certaines corrections pour Indexation des pages problèmes
 du site domain.fr

 - 0 app/Mail/Scanner.php:152  >>  App\Log->error('Mail Scanner - Account: 1, folder: INBOX, UID: 581, message: ERR_ILLEGAL_FIELD_VALUE||subject||OSSMailView||

Échec de certaines corrections pour Indexation des pages problèmes
 du site domain.fr
')
 - 1 modules/OSSMailScanner/crons/Scann.php:46  >>  App\Mail\Scanner->run()
 - 2 cron.php:100  >>  OSSMailScanner_Scann_Cron->process()
2024-09-23 22:13:01.2318 [info][[application]] -
$_SESSION = ['last_activity'=>1727122381.261789]
_HEADERS = []

Do you have any idea ? Thanks,

rskrzypczak commented 1 month ago

It seems that the subject of the email is the source of the problem here. It may contain HTML syntax or some other unacceptable characters. Also check if you have uft8mb4 or uft8mb3 database encoding. If you can, please provide the subject of the email.

vslonska commented 1 month ago

Hello, Thanks for the answer.

It's a message from Google Search Console. In the headers I have :

subject Échec de certaines corrections pour Indexation des pages problèmes du site mydomain.fr

fromGoogle Search Console Team <sc-noreply@google.com>

If I open the system.log file with a local text editor I see (with an encoding problem) : Échec de certaines corrections pour Indexation des pages problèmes

I don't see any encoding problem in the subject of the email in the inbox (Rouncube in Yetiforce or in the original mailbox of the provider).

The encoding of the database is correct I think : Screenshot 2024-09-24 at 09-28-13 Configuration serveur

I can send you the problematic email if you want.

I also have another error :

2024-09-23 23:59:19.2802 [error][[App\Fields\File]] - Error during file validation: mj_logo_with_text_color.svg | Size: 4362
 App\Exceptions\DangerousFile: ERR_FILE_ILLEGAL_FORMAT in app/Fields/File.php:1279
Stack trace:
#0 app/Fields/File.php(444): App\Fields\File->validateFormat()
#1 app/Fields/File.php(474): App\Fields\File->validate()
#2 app/Mail/Message/Imap.php(558): App\Fields\File->validateAndSecure()
#3 app/Mail/Message/Imap.php(528): App\Mail\Message\Imap->getFileFromImage()
#4 app/Mail/Message/Imap.php(378): App\Mail\Message\Imap->parseBody()
#5 app/Mail/Message/Imap.php(430): App\Mail\Message\Imap->getBody()
#6 app/Mail/ScannerAction/CreatedMail.php(68): App\Mail\Message\Imap->hasAttachments()
#7 modules/OSSMail/views/MailActionBar.php(50): App\Mail\ScannerAction\CreatedMail->process()
#8 include/main/WebUI.php(161): OSSMail_MailActionBar_View->process()
#9 index.php(26): Vtiger_WebUI->process()
#10 public_html/index.php(13): require('...')
#11 {main}