Have to debug what's happening.
Please replace function checkEmails() in /model/Cron.php with this (including taces)
public static function checkEmails() {
self::init();
global $globalCronMode, $globalCatchErrors;
$globalCronMode=true;
$globalCatchErrors=true;
require_once("../model/ImapMailbox.php"); // Imap management Class
if (! ImapMailbox::checkImapEnabled()) {
traceLog("ERROR - Cron::checkEmails() - IMAP extension not enabled in your PHP config. Cannot connect to IMAP Mailbox.");
return;
}
// IMAP must be enabled in Google Mail Settings
$emailEmail=Parameter::getGlobalParameter('cronCheckEmailsUser');
$emailPassword=Parameter::getGlobalParameter('cronCheckEmailsPassword');
$emailAttachmentsDir=dirname(__FILE__) . '/../files/attach';
$emailHost=Parameter::getGlobalParameter('cronCheckEmailsHost'); // {imap.gmail.com:993/imap/ssl}INBOX';
if (! $emailHost) {
traceLog("IMAP connection string not defined");
return;
}
$mailbox = new ImapMailbox($emailHost, $emailEmail, $emailPassword, $emailAttachmentsDir, 'utf-8');
$mails = array();
// Get some mail
$mailsIds = $mailbox->searchMailBox('UNSEEN UNDELETED');
if(!$mailsIds) {
debugTraceLog('Mailbox is empty'); // Will be a debug level trace
return;
}
include_once '../external/html2text/html2text.php';
foreach ($mailsIds as $mailId) {
$mail = $mailbox->getMail($mailId);
$mailbox->markMailAsUnread($mailId);
$body=$mail->textPlain;
traceLog('body='.$body);
$bodyHtml=$mail->textHtml;
traceLog('bodyHtml='.$bodyHtml);
if (! $body and $bodyHtml) {
$body=str_replace(array("</div>","</p>","<br>","<br/>","<br />"),
array("</div>\n","</p>\n","\n","\n","\n"), $bodyHtml);
$body=strip_tags($bodyHtml);
}
$class=null;
$id=null;
$msg=null;
$senderId=null;
// Class and Id of object
$posClass=strpos($body,'directAccess=true&objectClass=');
if ($posClass) { // It is a ProjeQtor mail
$posId=strpos($body,'&objectId=',$posClass);
$posEnd=strpos($body,'>',$posId);
$class=substr($body,$posClass+30,$posId-$posClass-30);
$id=substr($body,$posId+10,$posEnd-$posId-10);
} else {
continue;
}
// Message
$posEndMsg=strpos($body,"\r\n\r\n\r\n");
if ($posEndMsg) {
$msg=substr($body,0,$posEndMsg);
traceLog('msg='.$msg);
}
// Sender
$sender=$mail->fromAddress;
$crit=array('email'=>$sender);
$usr=new Affectable();
$usrList=$usr->getSqlElementsFromCriteria($crit,false,null,'idle asc, isUser desc, isResource desc');
if (count($usrList)) {
$senderId=$usrList[0]->id;
}
if (! $senderId) {
traceLog("Email message received from '$sender', not recognized as resource or user or contact : message not stored as note to avoid spamming");
$mailbox->markMailAsUnread($mailId);
continue;
}
$arrayFrom=array("\n","\r"," ");
$arrayTo=array("","","");
$class=str_replace($arrayFrom, $arrayTo, $class);
$id=str_replace($arrayFrom, $arrayTo, $id);
$obj=null;
if (SqlElement::class_exists($class) and is_numeric($id)) {
$obj=new $class($id);
}
if ($obj and $obj->id and $senderId) {
$note=new Note();
$note->refType=$class;
$note->refId=$id;
$note->idPrivacy=1;
$note->note=nl2br($msg);
$note->idUser=$senderId;
$note->creationDate=date('Y-m-d H:i:s');
$note->fromEmail=1;
$note->save();
$mailbox->markMailAsRead($mailId);
debugTraceLog("Note from '$sender' added on $class #$id");
} else {
$mailbox->markMailAsUnread($mailId);
}
}
}
Then Stop and Start Cron (important to take changes into account) and test email.
Post result (in log file) here.