AnsweredAssumed Answered

InboundEmails importOneEmail functionality inconsistent?

Question asked by Timothy Tran on Jul 10, 2018

Hello hello!

 

We've got a client that has some pretty heavy customized email queues that piggy back off the core Inbound Emails functionality. One feature involves a scheduler task that retrieves emails from associated Gmail accounts, to do this, it uses the InboundEmails.php importOneEmail function.

 

We've recently patched the system from 7.9.1 to 7.9.4 as recommended given the recent security updates. Ever since that update thought, this function is now sporadically returning false, however, even through it returns false, emails are still being created, but, non of the additional follow up custom code is being applied due to the false return.

 

Here's what our custom code looks like,

 

$importOneEmailResult = $ieX->importOneEmail($msgNo, $uid); 

 

// refactor this if statement if ($ieX->importOneEmail($msgNo, $uid)) {
if ($importOneEmailResult) {
// add to folder - THIS ONLY SOMETIMES RUNS NOW 
$sugarFolder->addBean($ieX->email);
if ($ieX->isPop3Protocol()) { 
$messagesToDelete[] = $msgNo;
} else { 
$messagesToDelete[] = $uid;
}

 

$userId = assignEmailToQueueFromRule($email_rules_cache,$ieX->email->from_addr,$ieX); 

 

We added some logging to the InboundEmails.php importOneEmail function just to trace what is happening,

 

Lines 4262 to 4275

///////////////////////////////////////////////////////////////////////
//// TO SUPPORT EMAIL 2.0
$this->email = $email;

$GLOBALS['log']->fatal('********************************* InboundEmail checking contents of email->et: '.$email->name.' - result: '.$this->email->et);
if(empty($this->email->et)) {
$email2initResult = $this->email->email2init();
$GLOBALS['log']->fatal('********************************* InboundEmail running email2init: '.$email->name.' - result: '.$email2initResult);
}

$GLOBALS['log']->fatal('********************************* InboundEmail returning true: '.$email->name);

return true;
}

 

Now the weird behavior is that we see a log message stating, 

"********************************* InboundEmail returning true: email name"

 

But then, the importOneEmail function returns false.

 

Has anyone out there experiences this oddness before? We've checked all the return statements in the importOneEmail function, they're definitely not being called given the pre return true log statement. Unless the email2init is performing some dark magic.

Outcomes