Search code examples
javaapacheimap

Apache Commons Net IMAPsClient List Command


I'm trying to connect to www.gmx.net via the apache commons net ImapsClient

I'm able to log in and to fetch messages from folders i know. but my problem is on listing folders.

JavaDoc tells me

boolean list(String refName, String mailboxName) Send a LIST command to the server.

whereat the RFC says send "" "*" to list all folders. so if i call

imap.list("", "*");

the server returns me

AAAB LIST *

AAAB BAD expected 1*ASTRING-CHAR / string instead of " "

[AAAB BAD expected 1*ASTRING-CHAR / string instead of " "]

so if i call

imap.list("/", "*");

the server returns me

AAAB LIST *

AAAB OK LIST completed

[AAAB OK LIST completed]

but no folders get listed. As i can select folders Inbox and Spamverdacht there are obviously more than NO folders.

FULL log of one of this 'empty results' is:

Using secure protocol: SSL

Connecting to server imap.gmx.net on 993

  • OK [CAPABILITY IMAP4rev1 CHILDREN ENABLE ID IDLE LIST-EXTENDED LIST-STATUS LITERAL+ MOVE NAMESPACE SASL-IR SORT SPECIAL-USE THREAD=ORDEREDSUBJECT UIDPLUS UNSELECT WITHIN AUTH=LOGIN AUTH=PLAIN] IMAP server ready H migmx029 104568 IMAP-0LaTV9-1ZTDW43mbH-00lcpb

AAAA LOGIN *******

AAAA OK LOGIN completed

AAAB LIST / *

AAAB OK LIST completed

[AAAB OK LIST completed]

AAAC LOGOUT

  • BYE Server logging out

AAAC OK LOGOUT completed

whats my mistake?


Solution

  • Sounds like it doesn't do proper escaping.

    Try imap.list("\"\"", "\"*\""), that is put in escaped quotes.