Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-85254

IMAP connection failure in Moodle 4.5 due to auth_type auto-detection (CHECK)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 4.5 regressions
    • Tasks

      After upgrading from Moodle 4.1 to 4.5, the Inbound Message (tool_messageinbound) scheduled task started failing with the error:

      tool_messageinbound/imapconnectfailure (Could not connect to IMAP server.)

      Cause:
      In Moodle 4.5 (possibly before), the IMAP connection uses rcube_imap_generic with 'auth_type' => 'CHECK', which triggers automatic detection of authentication mechanisms based on the IMAP server's advertised capabilities.

      On servers like Dovecot, which advertise mechanisms such as CRAM-MD5 and DIGEST-MD5 alongside LOGIN and PLAIN, the client attempts to use these stronger methods first. If the mailbox is only configured for standard LOGIN authentication, the connection fails without falling back properly.

      This behavior did not occur in Moodle 4.1, where IMAP connections worked reliably with the same server configuration.

      Workaround:
      Manually overriding the auth_type from 'CHECK' to 'LOGIN' in /admin/tool/messageinbound/classes/manager.php resolves the issue:

      $configuration['options'] = [
          'ssl_mode' => strtolower($CFG->messageinbound_hostssl),
          'auth_type' => 'LOGIN'
      ];

      Proposed Solution:

      Introduce a configurable option in the UI or config.php to explicitly set the desired auth_type for IMAP connections, defaulting to 'LOGIN' where appropriate. Alternatively, improve the detection logic to prefer LOGIN when advanced mechanisms like CRAM-MD5 or DIGEST-MD5 are advertised but not configured for use.

      Environment:

      • Moodle 4.5
      • Dovecot 2.3.x IMAP server (running on Plesk on Ubuntu 22)
      • IMAP authentication (username/password over SSL)

            Unassigned Unassigned
            scits Romeo Sulzer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.