go-imap
go-imap copied to clipboard
Cannot connect to Cyrus IMAP 2.5 - hangs on login
I am using the general example to Dial and Login to the IMAP server. I can DialTLS but I am failing to Login.
Code:
c, err := imapclient.DialTLS(imapServer, options)
if err != nil {
log.Fatalf("failed to dial IMAP server: %v", err)
}
defer c.Close()
if err := c.Login(userName, password).Wait(); err != nil {
log.Fatalf("failed to login: %v", err)
}
It hangs on the Wait(). If the Wait() is not specified, it passes through with: failed to login: &{T1 0xc000079260 <nil>}
I used the options := &imapclient.Options{ DebugWriter: os.Stdout, }
which prints out this:
T1 LOGIN "<redacted>" "<redacted>"
* OK [CAPABILITIES IMAP4rev1 LITERAL+ ID ENABLE AUTH=PLAIN AUTH=LOGIN SASL-IR] <redacted> Cyrus IMAP 2.5.10-55-gb6dbffa-Kolab-2.5.10-6.1.el7.kolab_16 server ready
T2 CAPABILITY
* CAPABILITY IMAP4rev1 LITERAL+ ID ENABLE ACL RIGHTS=kxten QUOTA MAILBOX-REFERRALS NAMESPACE UIDPLUS NO_ATOMIC_RENAME UNSELECT CHILDREN MULTIAPPEND BINARY CATENATE CONDSTORE ESEARCH SORT SORT=MODSEQ SORT=DISPLAY SORT=UID THREAD=ORDEREDSUBJECT THREAD=REFERENCES ANNOTATEMORE ANNOTATE-EXPERIMENT-1 METADATA LIST-EXTENDED LIST-STATUS LIST-MYRIGHTS WITHIN QRESYNC SCAN XLIST XMOVE MOVE SPECIAL-USE CREATE-SPECIAL-USE URLAUTH URLAUTH=BINARY X-NETSCAPE AUTH=PLAIN AUTH=LOGIN SASL-IR X-QUOTA=STORAGE X-QUOTA=MESSAGE X-QUOTA=X-ANNOTATION-STORAGE X-QUOTA=X-NUM-FOLDERS IDLE
T2 OK Completed
And the code stalls and never finishes.
I tried other IMAP servers and was able to connect to it. I am using the Cyrus IMAP server with several email clients - desktop, mobile, webmail and everything works OK.
When I looked at the outputs, it looks like it may be because it is missing something like OK LOGIN Completed
confirmation.
I have looked into the RFC 9051 and the LOGIN and it states:
6.2.3. LOGIN Command
Arguments:
user name
password
Responses:
no specific responses for this command
Result:
OK - login completed, now in authenticated state
NO - login failure: user name or password rejected
BAD - command unknown or arguments invalid
This makes me thinking that it is OK that the server does not respond to the LOGIN message (although, I would also rather see it does). But since it proceeds further with the CAPABILITY announcement it somewhat implies that the LOGIN went through OK.
Anyone came across this and is it a problem (unusual use case) with the imap package or is it a problem of the Cyrus IMAP server, or both?
Thanks in advance!