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

Can't create mailbox tobeconfirmed via imap with Courier / add support for IMAP namespace lookup

XMLWordPrintable

    • MOODLE_31_STABLE
    • MOODLE_31_STABLE
    • MDL-53315-imap-namespace
    • Hide

      Hack the inbox name specifically for courier

      Show
      Hack the inbox name specifically for courier
    • Hide

      TO TESTER - skip to the last part, Dan has done the first part for you.

      1. Setup incoming verp handling against a Courier email server ( Home ► Site administration ► Server ► Incoming mail configuration ► Mail settings
      2. Turn on imap debugging (see MDL-53314)
      3. Run the pickup cron task and you should see a failure in the imap trace around creating the folders that the message processing needs:

      C: 5 CREATE tobeconfirmed
      S: 5 NO Invalid mailbox name.
      >> Command 5 took 0.0435 seconds.
      Unable to connect to IMAP server. Failed with 'IMAP error reported by server.'
      

      Apply the patch and re-run, it should auto detect the imap namespace and create the correct folders:

      Connecting to mail.catalyst.net.nz as moodle@moodle.catalyst-au.net...
      ------------------------------
      >> Thu, 03 Mar 2016 23:21:41 +1100
      >> Connection to: imap://mail.catalyst.net.nz:993/
      >> Server connection took 3.1894 seconds.
      S: * OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE AUTH=PLAIN ACL ACL2=UNION] Courier-IMAP ready. Copyright 1998-2010 Double Precision, Inc.  See COPYING for distribution information.
      1 [AUTHENTICATE Command - method: PLAIN, username: moodle@moodle.catalyst-au.net]
      C: 2 CAPABILITY
      S: * CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE AUTH=PLAIN ACL ACL2=UNION
      S: 2 OK CAPABILITY completed
      >> Command 2 took 0.0446 seconds.
      Connection established.
      C: 3 NAMESPACE
      S: * NAMESPACE (("INBOX." ".")) NIL (("#shared." ".")("shared." "."))
      S: 3 OK NAMESPACE completed.
      >> Command 3 took 0.0464 seconds.
      C: 4 LIST "" INBOX
      C: 5 LIST "" INBOX.tobeconfirmed
      S: * LIST (\Unmarked \HasChildren) "." "INBOX"
      S: 4 OK LIST completed
      >> Command 4 took 0.0436 seconds.
      S: * LIST (\Unmarked \HasNoChildren) "." "INBOX.tobeconfirmed"
      S: 5 OK LIST completed
      >> Command 5 took 0.116 seconds.
      ......
      

      And then re-test in whatever other email servers are supported theoretically (eg gmail, exchange, etc) - it would be good to have a list in the wiki of at least which email servers this has been tested in.

      Show
      TO TESTER - skip to the last part, Dan has done the first part for you. Setup incoming verp handling against a Courier email server ( Home ► Site administration ► Server ► Incoming mail configuration ► Mail settings Turn on imap debugging (see MDL-53314 ) Run the pickup cron task and you should see a failure in the imap trace around creating the folders that the message processing needs: C: 5 CREATE tobeconfirmed S: 5 NO Invalid mailbox name. >> Command 5 took 0.0435 seconds. Unable to connect to IMAP server. Failed with 'IMAP error reported by server.' Apply the patch and re-run, it should auto detect the imap namespace and create the correct folders: Connecting to mail.catalyst.net.nz as moodle@moodle.catalyst-au.net... ------------------------------ >> Thu, 03 Mar 2016 23:21:41 +1100 >> Connection to: imap://mail.catalyst.net.nz:993/ >> Server connection took 3.1894 seconds. S: * OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE AUTH=PLAIN ACL ACL2=UNION] Courier-IMAP ready. Copyright 1998-2010 Double Precision, Inc. See COPYING for distribution information. 1 [AUTHENTICATE Command - method: PLAIN, username: moodle@moodle.catalyst-au.net] C: 2 CAPABILITY S: * CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE AUTH=PLAIN ACL ACL2=UNION S: 2 OK CAPABILITY completed >> Command 2 took 0.0446 seconds. Connection established. C: 3 NAMESPACE S: * NAMESPACE (("INBOX." ".")) NIL (("#shared." ".")("shared." ".")) S: 3 OK NAMESPACE completed. >> Command 3 took 0.0464 seconds. C: 4 LIST "" INBOX C: 5 LIST "" INBOX.tobeconfirmed S: * LIST (\Unmarked \HasChildren) "." "INBOX" S: 4 OK LIST completed >> Command 4 took 0.0436 seconds. S: * LIST (\Unmarked \HasNoChildren) "." "INBOX.tobeconfirmed" S: 5 OK LIST completed >> Command 5 took 0.116 seconds. ...... And then re-test in whatever other email servers are supported theoretically (eg gmail, exchange, etc) - it would be good to have a list in the wiki of at least which email servers this has been tested in.

      I'm having issues connecting inbounce imap fetching from courier (hence MDL-53314) which spits out this debug imap trace:

      S: * OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE AUTH=PLAIN ACL ACL2=UNION] Courier-IMAP ready. Copyright 1998-2010 Double Precision, Inc.  See COPYING for distribution information.
      1 [AUTHENTICATE Command - method: PLAIN, username: moodle@moodle.catalyst-au.net]
      C: 2 CAPABILITY
      S: * CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE AUTH=PLAIN ACL ACL2=UNION
      S: 2 OK CAPABILITY completed
      >> Command 2 took 0.0462 seconds.
      Connection established.
      C: 3 LIST "" INBOX
      C: 4 LIST "" tobeconfirmed
      S: * LIST (\Unmarked \HasChildren) "." "INBOX"
      S: 3 OK LIST completed
      >> Command 3 took 0.0448 seconds.
      S: 4 OK LIST completed
      >> Command 4 took 0.088 seconds.
      Unable to find the 'tobeconfirmed' mailbox - creating it.
      C: 5 CREATE tobeconfirmed
      S: 5 NO Invalid mailbox name.
      >> Command 5 took 0.0439 seconds.
      Unable to connect to IMAP server. Failed with 'IMAP error reported by server.'
      ... used 5 dbqueries
      ... used 3.6027870178223 seconds
      Scheduled task complete: Incoming email pickup (tool_messageinbound\task\pickup_task)
      C: 6 LOGOUT
      S: * BYE Courier-IMAP server shutting down
      S: 6 OK LOGOUT completed
      >> Command 6 took 0.0439 seconds.
      

      So it's having trouble making the folders, which I can fix by hacking this:

      --- a/admin/tool/messageinbound/classes/manager.php
      +++ b/admin/tool/messageinbound/classes/manager.php
      @@ -42,7 +42,7 @@ class manager {
           /**
            * @var string The mailbox to store messages in when they are awaiting confirmation.
            */
      -    const CONFIRMATIONFOLDER = 'tobeconfirmed';
      +    const CONFIRMATIONFOLDER = 'INBOX.tobeconfirmed';
       
           /**
            * @var string The flag for seen/read messages.
      

      Courier's FAQ says that the client should automatically lookup the folder namespace using the NAMESPACE extension

      http://www.courier-mta.org/FAQ.html#namespace

            brendanheywood Brendan Heywood
            brendanheywood Brendan Heywood
            Andrew Lyons Andrew Lyons
            Dan Poltawski Dan Poltawski
            Rajesh Taneja Rajesh Taneja
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

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