Suite 7.14.1 Inbound Email Cannot be Retrieved #5125

Open
opened 2026-02-20 16:30:00 -05:00 by deekerman · 13 comments
Owner

Originally created by @maarisk on GitHub (Nov 1, 2023).

Inbound e-mails are not retrieved. When user selects in Profile -> Inbound Accounts -> -> Test Connection, user gets error "Can not authenticate to IMAP server: The Auth_SASL package is required for DIGEST-MD5 authentication"

Expected Behavior

User sees inbound e-mails as well as Test Connection returns success.

Actual Behavior

Error message: Can not authenticate to IMAP server: The Auth_SASL package is required for DIGEST-MD5 authentication

Possible Fix

Steps to Reproduce

  1. Go to Profile -> Inbound Accounts and select your account to Edit
  2. Press Test Connection button

or

Go to e-mail inbox.

Context

As a result of this issue, cannot import neither incoming nor outgoing emails into CRM rendering this feature useless.

Your Environment

  • SuiteCRM Version used: 7.14.1
  • Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)): Safari 17.1 (macos 14.1, M2 Max)
  • Environment name and version (e.g. MySQL, PHP 7): PHP 7.4.33 (also getting the same issue on PHP 8.2.12)
  • Operating System and version (e.g Ubuntu 16.04): macOS 12.7.1
Originally created by @maarisk on GitHub (Nov 1, 2023). Inbound e-mails are not retrieved. When user selects in Profile -> Inbound Accounts -> <account> -> Test Connection, user gets error "Can not authenticate to IMAP server: The Auth_SASL package is required for DIGEST-MD5 authentication" #### Expected Behavior User sees inbound e-mails as well as Test Connection returns success. #### Actual Behavior Error message: Can not authenticate to IMAP server: The Auth_SASL package is required for DIGEST-MD5 authentication #### Possible Fix <!--- Not obligatory, but suggest a fix or reason for the bug --> #### Steps to Reproduce 1. Go to Profile -> Inbound Accounts and select your account to Edit 2. Press Test Connection button or Go to e-mail inbox. #### Context As a result of this issue, cannot import neither incoming nor outgoing emails into CRM rendering this feature useless. #### Your Environment <!--- Include as many relevant details about the environment you experienced the bug in --> * SuiteCRM Version used: 7.14.1 * Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)): Safari 17.1 (macos 14.1, M2 Max) * Environment name and version (e.g. MySQL, PHP 7): PHP 7.4.33 (also getting the same issue on PHP 8.2.12) * Operating System and version (e.g Ubuntu 16.04): macOS 12.7.1
Author
Owner

@ckangwei83 commented on GitHub (Nov 9, 2023):

Face similar issue. Somehow i notice the imap2 is not working fine. So i am trying to use Native instead. Made changes in file below.

modules/InboundEmail/InboundEmail.php line 8626

protected function getImapHandlerType(): string
{
        global $sugar_config;
        return isset($sugar_config['imap_handler'])?$sugar_config['imap_handler']:'imap2';
 }

By default it will return imap2 and will not trigger native method. So i introduce sugar_config and in the config_override.php to add in
$sugar_config['imap_handler'] = 'native';

There are still some issue whereby i am not able to list mailbox folder when doing configuration in inbound email. But i can enter the mailbox myself into the box and the inbound email process scheduler still works.

@ckangwei83 commented on GitHub (Nov 9, 2023): Face similar issue. Somehow i notice the imap2 is not working fine. So i am trying to use Native instead. Made changes in file below. modules/InboundEmail/InboundEmail.php line 8626 ```php protected function getImapHandlerType(): string { global $sugar_config; return isset($sugar_config['imap_handler'])?$sugar_config['imap_handler']:'imap2'; } ``` By default it will return imap2 and will not trigger native method. So i introduce sugar_config and in the config_override.php to add in `$sugar_config['imap_handler'] = 'native';` There are still some issue whereby i am not able to list mailbox folder when doing configuration in inbound email. But i can enter the mailbox myself into the box and the inbound email process scheduler still works.
Author
Owner

@MaxSprea commented on GitHub (Nov 17, 2023):

Hi, I had similar issues and with some trial & error I managed to make the native ImapHandler work.

The main cause of problems is the change in return types of several Imap related functions in PHP>=8.1

For example: imap_open returns an IMAP\Connection instance now (see here) instead of a resource and the functions in the native ImapHandler test for a valid resource (which now returns false).

I had to modify several functions of the ImapHandler to make it work, here are my modifications:

protected function setStream($stream, $validate = true)
  {
      //if ($validate && !is_resource($stream)) {
      if ($validate && $stream===false) { //stream is no longer a resource
          $this->logger->warn('ImapHandler trying to set a non valid resource az stream.');
      }
      $this->stream = $stream;
  }

  protected function getStream($validate = true)
  {
      //if ($validate && !is_resource($this->stream)) {
      if ($validate && $this->stream===false) { //stream is no longer a resuorce
          $this->logger->warn('ImapHandler trying to use a non valid resource stream.');
      }

      return $this->stream;
  }

  public function close()
  {
      $this->logCall(__FUNCTION__, func_get_args());
      if(imap_is_open($this->getStream())){ //check before closing otherwise imap_close throws an exception
          if (!$ret = imap_close($this->getStream())) {
              $this->log('IMAP close error');
          }
      }
      $this->logReturn(__FUNCTION__, $ret);

      return $ret;
  }

  public function getConnection()
  {
      $this->logCall(__FUNCTION__, func_get_args());
      if($this->getStream()===null){ //must check if stream is null and return false
          $ret=false;
      }
      else{
          $ret = $this->getStream();
      }
      $this->logReturn(__FUNCTION__, $ret);

      return $ret;
  }

  public function ping()
  {
      $this->logCall(__FUNCTION__, func_get_args());
      if($this->getStream()===null){
          $ret = false;
      }
      else{
          $ret = imap_is_open($this->getStream()); //imap_ping has problems and as of php8.2 this new function was introduced
      }
      $this->logReturn(__FUNCTION__, $ret);

      return $ret;
  }

  public function getHeaderInfo($msg_number, $fromLength = 0, $subjectLength = 0, $defaultHost = null)
  {
      $this->logCall(__FUNCTION__, func_get_args());
      $ret = imap_headerinfo($this->getStream(), $msg_number, $fromLength, $subjectLength); //parameter defaultHost removed as of php 8
      if (!$ret) {
          $this->log('IMAP get header info error');
      }
      $this->logReturn(__FUNCTION__, $ret);

      return $ret;
  }

  public function isValidStream($stream): bool
  {
      if(!isset($stream) || $stream===false){
          return false;
      }
      else{
          return true;
      }
      //return is_resource($stream); //stream is not a resource anymore
  }

Note that the imap_is_open function i used in ping() and close() was introduced in PHP 8.2 to solve some issues on the imap_ping function, if you have a previous PHP version it will not work.

Please keep in mind this was a quick hack as I needed to make it work ASAP, take the time to test it and correct any errors before using in a production environment.

These modifications also work on suitecrm 8.4.

@MaxSprea commented on GitHub (Nov 17, 2023): Hi, I had similar issues and with some trial & error I managed to make the native ImapHandler work. The main cause of problems is the change in return types of several Imap related functions in PHP>=8.1 For example: imap_open returns an IMAP\Connection instance now (see [here](https://www.php.net/manual/en/function.imap-open.php)) instead of a resource and the functions in the native ImapHandler test for a valid resource (which now returns false). I had to modify several functions of the ImapHandler to make it work, here are my modifications: ``` protected function setStream($stream, $validate = true) { //if ($validate && !is_resource($stream)) { if ($validate && $stream===false) { //stream is no longer a resource $this->logger->warn('ImapHandler trying to set a non valid resource az stream.'); } $this->stream = $stream; } protected function getStream($validate = true) { //if ($validate && !is_resource($this->stream)) { if ($validate && $this->stream===false) { //stream is no longer a resuorce $this->logger->warn('ImapHandler trying to use a non valid resource stream.'); } return $this->stream; } public function close() { $this->logCall(__FUNCTION__, func_get_args()); if(imap_is_open($this->getStream())){ //check before closing otherwise imap_close throws an exception if (!$ret = imap_close($this->getStream())) { $this->log('IMAP close error'); } } $this->logReturn(__FUNCTION__, $ret); return $ret; } public function getConnection() { $this->logCall(__FUNCTION__, func_get_args()); if($this->getStream()===null){ //must check if stream is null and return false $ret=false; } else{ $ret = $this->getStream(); } $this->logReturn(__FUNCTION__, $ret); return $ret; } public function ping() { $this->logCall(__FUNCTION__, func_get_args()); if($this->getStream()===null){ $ret = false; } else{ $ret = imap_is_open($this->getStream()); //imap_ping has problems and as of php8.2 this new function was introduced } $this->logReturn(__FUNCTION__, $ret); return $ret; } public function getHeaderInfo($msg_number, $fromLength = 0, $subjectLength = 0, $defaultHost = null) { $this->logCall(__FUNCTION__, func_get_args()); $ret = imap_headerinfo($this->getStream(), $msg_number, $fromLength, $subjectLength); //parameter defaultHost removed as of php 8 if (!$ret) { $this->log('IMAP get header info error'); } $this->logReturn(__FUNCTION__, $ret); return $ret; } public function isValidStream($stream): bool { if(!isset($stream) || $stream===false){ return false; } else{ return true; } //return is_resource($stream); //stream is not a resource anymore } ``` Note that the imap_is_open function i used in ping() and close() was introduced in PHP 8.2 to solve some issues on the imap_ping function, if you have a previous PHP version it will not work. Please keep in mind this was a quick hack as I needed to make it work ASAP, take the time to test it and correct any errors before using in a production environment. These modifications also work on suitecrm 8.4.
Author
Owner

@meierwitt commented on GitHub (Jan 5, 2024):

@MaxSprea In which file did you make the changes? Is it:
include/Imap/ImapHandler.php

@meierwitt commented on GitHub (Jan 5, 2024): @MaxSprea In which file did you make the changes? Is it: include/Imap/ImapHandler.php
Author
Owner

@meierwitt commented on GitHub (Jan 5, 2024):

Hello, I have the same problem with SuiteCRM 7.14.2 and PHP 8.2 on a Linux Server with IMAP from netcup.de ISP

@meierwitt commented on GitHub (Jan 5, 2024): Hello, I have the same problem with SuiteCRM 7.14.2 and PHP 8.2 on a Linux Server with IMAP from netcup.de ISP
Author
Owner

@meierwitt commented on GitHub (Jan 5, 2024):

O.k. - thanks to @MaxSprea and @ckangwei83 - I tested this and it works for me.

Frank

@meierwitt commented on GitHub (Jan 5, 2024): O.k. - thanks to @MaxSprea and @ckangwei83 - I tested this and it works for me. Frank
Author
Owner

@chris001 commented on GitHub (Jan 6, 2024):

This needs a PR so Inbound Email will work on PHP 8.1+. Anyone?

@chris001 commented on GitHub (Jan 6, 2024): This needs a PR so Inbound Email will work on PHP 8.1+. Anyone?
Author
Owner

@maarisk commented on GitHub (Jan 11, 2024):

None of the solutions provided here work for me. Switched back to PHP 7.4 due to other issues, but inbound e-mails still don't work and get the same error message.

@maarisk commented on GitHub (Jan 11, 2024): None of the solutions provided here work for me. Switched back to PHP 7.4 due to other issues, but inbound e-mails still don't work and get the same error message.
Author
Owner

@chris001 commented on GitHub (Jan 15, 2024):

The fix is:

pear channel-update pear.php.net
pear install Auth_SASL
sudo systemctl reload apache2  # for linux
sudo systemctl reload php-fpm  # for linux
sudo /opt/bitnami/scripts/apache/reload.sh # for bitnami container

Run these commands on your systems, and report back your results.

@chris001 commented on GitHub (Jan 15, 2024): The fix is: ``` pear channel-update pear.php.net pear install Auth_SASL sudo systemctl reload apache2 # for linux sudo systemctl reload php-fpm # for linux sudo /opt/bitnami/scripts/apache/reload.sh # for bitnami container ``` Run these commands on your systems, and report back your results.
Author
Owner

@MaxSprea commented on GitHub (Jan 18, 2024):

The fix is:

pear channel-update pear.php.net
pear install Auth_SASL
sudo systemctl reload apache2  # for linux
sudo systemctl reload php-fpm  # for linux
sudo /opt/bitnami/scripts/apache/reload.sh # for bitnami container

Run these commands on your systems, and report back your results.

Thanks, I can confirm this fixes the issue with most IMAP servers I tried except from Hetzner's where I get this response:

[FATAL] An Imap error detected: "Can not authenticate to IMAP server: A0001 BAD Mate, try AUTHENTICATE <mechanism>"
[FATAL] An Imap error detected: "IMAP open error: Can not authenticate to IMAP server: A0001 BAD Mate, try AUTHENTICATE <mechanism>"
[FATAL] An Imap error detected: "IMAP open error | debug data"
[FATAL] An Imap error detected: "ImapHandler:open: {mail.your-server.de:993/service=imap/ssl/tls/validate->cert/secure}INBOX"
[FATAL] An Imap error detected: "ImapHandler:open: xxxxxxxxxxxxxxxxxxx"
[FATAL] An Imap error detected: "ImapHandler:open: password is empty: no"
[FATAL] An Imap error detected: "ImapHandler:open: 0"
[FATAL] An Imap error detected: "IMAP open error | debug data end "

I will try troubleshooting this as soon as I have some free time as searching for the specific error did not yield any useful solution.

@MaxSprea commented on GitHub (Jan 18, 2024): > The fix is: > > ``` > pear channel-update pear.php.net > pear install Auth_SASL > sudo systemctl reload apache2 # for linux > sudo systemctl reload php-fpm # for linux > sudo /opt/bitnami/scripts/apache/reload.sh # for bitnami container > ``` > > Run these commands on your systems, and report back your results. Thanks, I can confirm this fixes the issue with most IMAP servers I tried except from Hetzner's where I get this response: >[FATAL] An Imap error detected: "Can not authenticate to IMAP server: A0001 BAD Mate, try AUTHENTICATE \<mechanism\>" >[FATAL] An Imap error detected: "IMAP open error: Can not authenticate to IMAP server: A0001 BAD Mate, try AUTHENTICATE \<mechanism\>" >[FATAL] An Imap error detected: "IMAP open error | debug data" >[FATAL] An Imap error detected: "ImapHandler:open: {mail.your-server.de:993\/service=imap\/ssl\/tls\/validate->cert\/secure}INBOX" >[FATAL] An Imap error detected: "ImapHandler:open: xxxxxxxxxxxxxxxxxxx" >[FATAL] An Imap error detected: "ImapHandler:open: password is empty: no" >[FATAL] An Imap error detected: "ImapHandler:open: 0" >[FATAL] An Imap error detected: "IMAP open error | debug data end " I will try troubleshooting this as soon as I have some free time as searching for the specific error did not yield any useful solution.
Author
Owner

@pgorod commented on GitHub (Jan 18, 2024):

If this is a matter of installing a component on the server, it's not a SuiteCRM bug - but given that email configuration in SuiteCRM is already more than complex enough, I wonder if a simple PR could be made to just make the situation obvious?

Like print something in the screen or in the logs saying what is missing.

@pgorod commented on GitHub (Jan 18, 2024): If this is a matter of installing a component on the server, it's not a SuiteCRM bug - but given that email configuration in SuiteCRM is already more than complex enough, I wonder if a simple PR could be made to just make the situation obvious? Like print something in the screen or in the logs saying what is missing.
Author
Owner

@chris001 commented on GitHub (Jan 20, 2024):

@MaxSprea
Could you ask Hetzner tech support, what exactly does their IMAP server mean by that error message, "A0001 BAD Mate, try AUTHENTICATE <mechanism>"

@chris001 commented on GitHub (Jan 20, 2024): @MaxSprea Could you ask Hetzner tech support, what exactly does their IMAP server mean by that error message, "`A0001 BAD Mate, try AUTHENTICATE <mechanism>`"
Author
Owner

@maarisk commented on GitHub (Mar 10, 2024):

The fix is:

pear channel-update pear.php.net
pear install Auth_SASL
sudo systemctl reload apache2  # for linux
sudo systemctl reload php-fpm  # for linux
sudo /opt/bitnami/scripts/apache/reload.sh # for bitnami container

Run these commands on your systems, and report back your results.

With Kerio Connect mailserver this doesn't fix an issue.

Installed packages, channel pear.php.net:

Package Version State
Archive_Tar 1.4.14 stable
Auth_SASL 1.2.0 stable
Console_Getopt 1.4.3 stable
PEAR 1.10.13 stable
Structures_Graph 1.1.1 stable
XML_Util 1.4.5 stable

php.ini points include_path to PEAR package dir.

@maarisk commented on GitHub (Mar 10, 2024): > The fix is: > > ``` > pear channel-update pear.php.net > pear install Auth_SASL > sudo systemctl reload apache2 # for linux > sudo systemctl reload php-fpm # for linux > sudo /opt/bitnami/scripts/apache/reload.sh # for bitnami container > ``` > > Run these commands on your systems, and report back your results. With Kerio Connect mailserver this doesn't fix an issue. Installed packages, channel pear.php.net: ========================================= Package Version State Archive_Tar 1.4.14 stable **Auth_SASL 1.2.0 stable** Console_Getopt 1.4.3 stable PEAR 1.10.13 stable Structures_Graph 1.1.1 stable XML_Util 1.4.5 stable php.ini points include_path to PEAR package dir.
Author
Owner

@chris001 commented on GitHub (Mar 10, 2024):

@maarisk please paste the text of the error messages coming from your Kerio Connect IMAP server.
Also, what's your Security Policy settings on this screen:
security-built-into-your-business-email

@chris001 commented on GitHub (Mar 10, 2024): @maarisk please paste the text of the error messages coming from your Kerio Connect IMAP server. Also, what's your Security Policy settings on this screen: ![security-built-into-your-business-email](https://github.com/salesagility/SuiteCRM/assets/259416/d2ad37de-aace-4f8f-99e3-376da20b7a92)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SuiteCRM-SuiteCRM#5125
No description provided.