[Tickets #14330] IMP sends IMAP commands without the namespace
noreply at bugs.horde.org
noreply at bugs.horde.org
Fri Apr 15 02:06:33 UTC 2016
DO NOT REPLY TO THIS MESSAGE. THIS EMAIL ADDRESS IS NOT MONITORED.
Ticket URL: https://bugs.horde.org/ticket/14330
------------------------------------------------------------------------------
Ticket | 14330
Created By | quinn at strangecode.com
Summary | IMP sends IMAP commands without the namespace
Queue | Horde Groupware Webmail Edition
Version | 5.2.0
Type | Bug
State | Unconfirmed
Priority | 3. High
Milestone |
Patch |
Owners |
------------------------------------------------------------------------------
quinn at strangecode.com (2016-04-15 02:06) wrote:
I have had difficulty setting the IMAP path prefix in horde webmail
5.2 on a CentOS 6 server running Courier-IMAP 4.1.2. When creating
folders I was getting the error, "The mailbox 'New folder' was not
created. This is what the server said: IMAP error reported by server."
The imp_imap debug log shows that it is trying to create folders
without the `INBOX.` prefix, which I think is the reason it is failing:
S: * OK [CAPABILITY IMAP4rev1] Courier-IMAP ready. Copyright 1998-2005
Double Precision, Inc. See COPYING for distribution information.
C: 1 LOGIN quinn at example.com [PASSWORD]
S: 1 OK LOGIN Ok.
C: 2 LSUB "" New folder
S: 2 OK LSUB completed
C: 3 LIST "" New folder
S: 3 OK LIST completed
C: 4 CREATE New folder
S: 4 NO Invalid mailbox name.
C: 5 LOGOUT
S: * BYE Courier-IMAP server shutting down
S: 5 OK LOGOUT completed
I *am* able to create a folder if I manually include the IMAP prefix
to its name, i.e. I go to Folder Actions > Create Mailbox and then use
a folder name literally as `INBOX.New folder`. The new folder is created
with that name literally and `INBOX.New folder` is created on the server and
is displayed in IMP's sidebar. =\
As far as I can tell, this is configured using the 'namespace' option
in backends.local.php, but I have tried the following variations with
no success:
'namespace' => array('INBOX.')
'namespace' => array('#INBOX.')
'namespace' => array('INBOX/')
'namespace' => array('#INBOX/')
I believe the correct method of setting the IMAP path prefix is to
define the following in backends.local.php:
'namespace' => array('INBOX.'),
However, that alone has not solved the problem. I may have found
issues with horde/imp or our server configuration. Now, even with the
namespace specified thusly, IMP is still sending IMAP commands without
the namespace (i.e., `CREATE New folder` instead of `CREATE INBOX.New
folder`).
I have read the source code of horde/imp and found the following
changes were required for this to work:
## /var/www/html/horde/imp/lib/Imap.php : 474
The `getNamespace()` function defined here would return null when the
specified mailbox was the default, despite `$this->getNamespaces()`
returning a valid result. To solve this I added the following at line
474:
if ($mailbox === self::NS_DEFAULT && $ns->count() == 1) {
return end(end($ns));
}
## /usr/share/pear/Horde/Imap/Client/Base.php : 742
Here, the name of the namespace is an array and would result in an
array-to-string conversion, with the resulting namespace name `Array`
instead of the correct name `INBOX`. I've added a tertiary clause to
test if it is an array before assigning the value. Secondly, the
namespace name lacking the delimiter would result in the use of folder
names such as `INBOXNew folder` instead of `INBOX.New folder` (because
in other parts of the code where the namespace is used the namespace
is concatenated with the folder name with no delimiter), so I added
the delimiter to the name here. The following is a modification of
line 742:
$ob->name = (is_array($val) ? end($val) : $val) . $val['delimiter'];
With these two changes, horde/imp is now successfully creating
folders, displaying folders, auto-creating special folders, and moving
messages between folders. The IMAP transactions now send the prefix
correctly:
S: * OK [CAPABILITY IMAP4rev1] Courier-IMAP ready. Copyright
1998-2005 Double Precision, Inc. See COPYING for distribution
information.
C: 1 LOGIN q at asdf.com [PASSWORD]
S: 1 OK LOGIN Ok.
C: 2 LIST "" INBOX.
S: * LIST (\Marked \HasChildren) "." "INBOX"
S: 2 OK LIST completed
C: 3 LSUB "" "INBOX.New folder"
S: 3 OK LSUB completed
C: 4 LIST "" "INBOX.New folder"
S: 4 OK LIST completed
C: 5 CREATE "INBOX.New folder"
S: 5 OK "INBOX.New folder" created.
C: 6 LSUB "" "INBOX.New folder"
S: 6 OK LSUB completed
C: 7 LIST "" "INBOX.New folder"
S: * LIST (\HasNoChildren) "." "INBOX.New folder"
S: 7 OK LIST completed
C: 8 LOGOUT
S: * BYE Courier-IMAP server shutting down
S: 8 OK LOGOUT completed
If I have discovered bugs in horde/imp 5.2, please let me know how
best I can contribute these changes (pull request on github?) or if
you believe this is a problem with my Courier IMAP configuration, I
would appreciate some help identifying if that may be the case.
Copied below is IMP's imap log output during a successful folder
creation operation (also so you can see imap capabilities, etc).
------------------------------
>> Mon, 08 Feb 2016 22:08:14 -0600
>> Connection to: imap://localhost:993/
>> Server connection took 0.0094 seconds.
S: * OK [CAPABILITY IMAP4rev1] Courier-IMAP ready. Copyright 1998-2005
Double Precision, Inc. See COPYING for distribution information.
C: 1 LOGIN q at asdf.com [PASSWORD]
S: 1 OK LOGIN Ok.
>> Command 1 took 0.0381 seconds.
>> CACHE: Using the Horde_Imap_Client_Cache_Backend_Cache storage driver.
C: 2 LIST "" INBOX.
S: * LIST (\Marked \HasChildren) "." "INBOX"
S: 2 OK LIST completed
>> Command 2 took 0.077 seconds.
C: 3 LSUB "" "INBOX.New folder"
S: 3 OK LSUB completed
>> Command 3 took 0.0014 seconds.
C: 4 LIST "" "INBOX.New folder"
S: 4 OK LIST completed
>> Command 4 took 0.0006 seconds.
C: 5 CREATE "INBOX.New folder"
S: 5 OK "INBOX.New folder" created.
>> Command 5 took 0.0087 seconds.
C: 6 LSUB "" "INBOX.New folder"
S: 6 OK LSUB completed
>> Command 6 took 0.0003 seconds.
C: 7 LIST "" "INBOX.New folder"
S: * LIST (\HasNoChildren) "." "INBOX.New folder"
S: 7 OK LIST completed
>> Command 7 took 0.0008 seconds.
C: 8 LOGOUT
S: * BYE Courier-IMAP server shutting down
S: 8 OK LOGOUT completed
>> Command 8 took 0.0012 seconds.
More information about the bugs
mailing list