Suite8: InboundEmail::connectMailserver - Invalid port provided: '993'. See valid_imap_ports config

I finally get a working upgrade to Suite8, but now have email issues again :confused:

I have set up office365 as provider, and authenticated the connector. Outgoing email is working fine, however incoming email seems to be broken again.

According to office365, the incoming IMAP port should be 993 with SSL enabled:

However the log shows however the suite error log shows:

InboundEmail::connectMailserver - Invalid port provided: ‘993’. See valid_imap_ports config.

No other errors.

I can see the error is thrown by modules/InboundEmail/InboundEmail.php,

if (empty($this->port) || !in_array($this->port, $sugar_config[‘valid_imap_ports’] ?? [], true)) {
$GLOBALS[‘log’]->fatal(“InboundEmail::connectMailserver - Invalid port provided: '” . ($this->port ?? ‘’) . “'. See valid_imap_ports config.”);
return $mod_strings[‘ERR_INVALID_PORT’] ?? “Invalid port”;

Given the log line includes the port number it cant be empty, however the valid_imap_ports defined in include/utils.php has

‘valid_imap_ports’ => [
‘110’, ‘143’, ‘993’, ‘995’

any ideas why this could be?

Have you gone over this setup guide for Microsoft O365 in case incoming email not be setup right.

Can you check in the database and see if the email account is indeed saved as “993”. I kind of remember a bug where the SSL wasn’t saving in the DB for the configuration, but it maybe that the port is not saving. I would double check that if you know how to check in the DB.

@pstevens , i’ve checked and port 993 is set in the database

@chris001, yes ive gone through this and can authenticate ok with API permissions set up in Entra.

The office settings must be correct as the email was working ok on the 7.13.1 version, which I upgraded to 8.4.1

Hey @Bungle,

Do you have valid_imap_ports on your config.php or config_override.php?

From the snippet you sent it seems like it is looking into sugar_config - !in_array($this->port, $sugar_config[‘valid_imap_ports’] ?? [], true)) {

If you don’t I would just add the following to your config.php or you can do a Repair Config

‘valid_imap_ports’ => [
‘110’, ‘143’, ‘993’, ‘995’

Hi @anthony.oak.castro,

I added that to the config_override.php and ran a repair, i no longer get the port error message, but when trying to load a folder a window pops up and quickly disappears. Suitecrm shows nothing in the log, but apache has the following:

PHP Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, string given in /var/www/html/public/legacy/modules/InboundEmail/InboundEmail.php:6386\nStack trace:\n#0 /var/www/html/public/legacy/modules/InboundEmail/InboundEmail.php(6386): in_array()\n#1 /var/www/html/public/legacy/modules/InboundEmail/Popup.php(138): InboundEmail->connectMailserver()\n#2 /var/www/html/public/legacy/include/MVC/View/SugarView.php(800): include_once(‘…’)\n#3 /var/www/html/public/legacy/include/MVC/View/views/view.classic.php(72): SugarView->includeClassicFile()\n#4 /var/www/html/public/legacy/include/MVC/View/SugarView.php(210): ViewClassic->display()\n#5 /var/www/html/public/legacy/include/MVC/Controller/SugarController.php(432): SugarView->process()\n#6 /var/www/html/public/legacy/include/MVC/Controller/SugarController.php(363): SugarController->processView()\n#7 /var/www/html/public/legacy/include/MVC/SugarApplication.php(101): SugarController->execute()\n#8 /var/www/html/public/legacy/index.php(52): SugarApplication->execute()\n#9 {main}\n thrown in /var/www/html/public/legacy/modules/InboundEmail/InboundEmail.php on line 6386, referer:

sorry not sure how to format that so its more readable

doh, scrap that!

I just realised what i had done, i couldnt figure how to put an array in config_override so just put port 993 to test.

Going back to follow your message properly and adding the array to config.php, and it now works!!! (apart from subject and from fields are empty - but that’s another issue i suppose)

The array is passed rather than a single string !

Thank you so much!!

‘valid_imap_ports’ => array(
1 => ‘110’,
2 => ‘143’,
3 => ‘993’,
4 => ‘995’,

haven’t tested (as I use port 993 and never faced these issues).

A curious situation, I don’t have one single line entry with “valid_imap_ports” on my SuiteCRM install:

[root@web suitecrm]# egrep -rni 'valid_imap_ports' .
[root@web suitecrm]# egrep -rni 'valid_imap_*' .
[root@web suitecrm]# 

Same problem. After upgrade from 8.4.1 to 8.4.2 i got Invalid port provided: ‘993’
Then i added this to config.php:
‘valid_imap_ports’ =>
array (
0 => ‘110’,
1 => ‘143’,
2 => ‘993’,
0 => ‘995’,

Now when i test a connection a window pops up and quickly disappears. Emails module shows no emails.

I believe this code only came into SuiteCRM precisely between 8.4.1 and 8.4.2. It’s new.

And I guess 993 should be in there as a default…

EDIT: it is!

I guess the only thing that is wrong is that for people with upgrades, maybe this code in make_sugar_config never runs to update the config:

Maybe in Admin / Repairs / Rebuild config this can be fixed without having to change any files manually. I wouldn’t test this without backing up my config.php first, though.

Feels like this 8.4.2 version is good to go back to BETA.

Also, what exactly is the point of adding a setting that does not work when before was working without problems?
Also, I’m really having some difficulties understanding why these changes are introduced in a patch update instead of a minor at least. Makes no sense. …

1 Like

I restored 8.4.1 from backup. Did upgrade to 8.4.2. Quick repair. Left it over night. Added ports to config. Email module is not empty. IT WORKS.