Suitecrm: 7.10.19 Auto Import and CreateCase not working with Office 365

Created on 4 Oct 2019  路  7Comments  路  Source: salesagility/SuiteCRM

I have and upgrade SuiteCRM from 7.8.27. to 7.10.19. and auto import with auto create case is no longer working with Office 365.
For GMAIL it is working.

Issue

I have managed to pinpoint line of code where the problem is:
_modules/Schedulers/AddJobsHere.php
code:
function: pollMonitoredInboxesAOP
`$GLOBALS['log']->debug('Trying to connect to mailserver for [ ' . $inboundEmailRow['name'] . ' ]');
if ($connectToMailServer) {
$GLOBALS['log']->debug('Connected to mailserver');

        if (!$aopInboundEmailX->isPop3Protocol()) {
            **$newMsgs = $aopInboundEmailX->getNewMessageIds();**
        }

        **if (is_array($newMsgs))** {
            $current = 1;`

Here is the funniest and from the developer side most horrible part of code.
This " if (is_array($newMsgs))" in my case is FALSE, and there is NONE check for that. So the process simply stops at that part and nothing happens, no error, no info.
Real stopper is in the line up : " $newMsgs = $aopInboundEmailX->getNewMessageIds();", where the return value is somehow unclear, beacuse of the problem with Office365.
This function is in the file: modules/InboundEmail/InboundEmail.php, function: getNewMessageIds .
For me this line returns nothing: $ret = $this->getImap()->search('UNDELETED UNSEEN');, or to be correct returns false. This false passes to a count function in logging and it says that there is "1 new Messages", returns that in "pollMonitoredInboxesAOP", checks if the value is array (FALSE != array), and code does no more ?!?!

Maybe I am totally wrong and have some major issues on my side, but the same code works with GMAIL but simply won't work with Office365 and code gives me no meaningful error.

Expected Behavior

To work like with GMAIL.

Actual Behavior

I can see the mail as it is on mail server, I can open it or manually import it, but automation is not working.

Possible Fix

Steps to Reproduce


  1. Create InboundMail with Office365 account with auto-import and auto-creation
  2. Send a mail to that email address
  3. Look in CRM that email is not imported and case is not created
  4. Repeat the whole process with GMAIL and it is working

Context

I can not use my mail any more with this functionality, and CRM for this part is useless.

Your Environment

  • SuiteCRM Version used: 7.10.19.
  • Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)):
  • Environment name and version (e.g. MySQL, PHP 7): PHP 7.1
  • Operating System and version (e.g Ubuntu 16.04): Debian 9
AreaConfig Important Fix Proposed Bug

Most helpful comment

OK guys, I see that nobody has this problem except me, and nobody left any comment, so I had to disassemble CRM email myself.
Point is, I have found the problem and a solution.

PROBLEM:
_include/Imap/ImapHandler.php_
Function: _public function search($criteria, $options = SE_FREE, $charset = null)_
BUG: _$emailCharset = !empty($charset) ? $charset : $this->charset;_
For some reason, this charset is never set up in my code, so this is always empty. Gmail has no problem with this, but Microsoft has. For MS this has to be "US-ASCII".

SOLUTION:
Either hard code charset to "US-ASCII", or improve code to use "US-ASCII" when the charset is empty or if you are trying to read MS server.

I hope this would help someone.
Filip

All 7 comments

OK guys, I see that nobody has this problem except me, and nobody left any comment, so I had to disassemble CRM email myself.
Point is, I have found the problem and a solution.

PROBLEM:
_include/Imap/ImapHandler.php_
Function: _public function search($criteria, $options = SE_FREE, $charset = null)_
BUG: _$emailCharset = !empty($charset) ? $charset : $this->charset;_
For some reason, this charset is never set up in my code, so this is always empty. Gmail has no problem with this, but Microsoft has. For MS this has to be "US-ASCII".

SOLUTION:
Either hard code charset to "US-ASCII", or improve code to use "US-ASCII" when the charset is empty or if you are trying to read MS server.

I hope this would help someone.
Filip

Filip, thank you.
Your solution solved this problem with an Office 365 account for me as well.

Original: public function search($criteria, $options = SE_FREE, $charset = null)

Modified: public function search($criteria, $options = SE_FREE, $charset = "US-ASCII")

@mattlorimer In the official release note I don't see any thanks to me. I am not egoistic but this is not the first time I have solved some of the issues that have great influence in using CRM and THANK YOU would be nice.

@fcorluka might be because I had already created the fix with #8708

@tsmgeek so my error is not creating pull request although my FIX is made year ago.

@fcorluka Thanks for highlighting this,

I think we must have only listed those who did merged PR's, it doesn't acknowledge those who reported issue,

We will have to review this

Was this page helpful?
0 / 5 - 0 ratings