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

Incorrect mailbox path generated in tool_messageinbound due to double delimiter in IMAP namespace handling

XMLWordPrintable

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

      In Moodle 4.5 (possibly starting from 4.2), the Inbound Message (tool_messageinbound) task attempts to verify and create required IMAP folders. When connecting to a Dovecot IMAP server, the task repeatedly logs:
      Unable to find the 'INBOX..tobeconfirmed' mailbox - creating it.

      This occurs on every run, despite the mailbox folder already existing.

      Cause:
      The issue stems from how Moodle constructs the mailbox path in the get_confirmation_folder() method within /admin/tool/messageinbound/classes/manager.php. Moodle concatenates the personal namespace and delimiter returned by the IMAP server with the confirmation folder name.

      If the IMAP server (e.g., Dovecot) returns a namespace that already includes a trailing delimiter, Moodle appends the delimiter again, resulting in a malformed mailbox path like:
      INBOX..tobeconfirmed

      Workaround:
      Modify get_confirmation_folder() to check whether the namespace already ends with the delimiter before appending it:

      if (substr($nspersonal[0], -1) === $nspersonal[1]) {
          $this->imapnamespace = $nspersonal[0];
      } else {
          $this->imapnamespace = $nspersonal[0] . $nspersonal[1];
      }

      This prevents the double delimiter and ensures correct folder detection.

      Environment:

      • Moodle 4.5
      • Dovecot 2.3.x IMAP server (running on Plesk w/ Ubuntu 22)
      • Default IMAP namespace configuration (personal namespace: INBOX. with delimiter ".")

            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.