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.
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.
To work like with GMAIL.
I can see the mail as it is on mail server, I can open it or manually import it, but automation is not working.
I can not use my mail any more with this functionality, and CRM for this part is useless.
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
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