Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot connect to Cyrus IMAP 2.5 - hangs on login #600

Open
tomas-kucera opened this issue Mar 17, 2024 · 4 comments
Open

Cannot connect to Cyrus IMAP 2.5 - hangs on login #600

tomas-kucera opened this issue Mar 17, 2024 · 4 comments

Comments

@tomas-kucera
Copy link

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!

@emersion emersion added the bug label Mar 18, 2024
@emersion
Copy link
Owner

emersion commented Mar 18, 2024

Hm, weird. The server sends a response to T2 but not T1. Does it help to add c.WaitGreeting before c.Login?

@tomas-kucera
Copy link
Author

Hm, weird. The server sends a response to T2 but not T1. Does it help to add c.WaitGreeting before c.Login?

Thanks! Yes! It does! It works now! The output now looks like this:

* 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
T1 LOGIN "<redacted>" "<redacted>"
T2 CAPABILITY
T1 OK [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 LOGINDISABLED AUTH=PLAIN AUTH=LOGIN X-QUOTA=STORAGE X-QUOTA=MESSAGE X-QUOTA=X-ANNOTATION-STORAGE X-QUOTA=X-NUM-FOLDERS IDLE] User logged in SESSIONID=<redacted>
T3 LIST "" "%"
* 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 LOGINDISABLED AUTH=PLAIN AUTH=LOGIN X-QUOTA=STORAGE X-QUOTA=MESSAGE X-QUOTA=X-ANNOTATION-STORAGE X-QUOTA=X-NUM-FOLDERS IDLE
T2 OK Completed
* LIST (\Noinferiors \HasNoChildren) "/" INBOX
* LIST (\HasNoChildren) "/" Archive
* LIST (\HasNoChildren) "/" Drafts
* LIST (\HasNoChildren) "/" Junk
* LIST (\HasNoChildren) "/" Sent
* LIST (\HasNoChildren) "/" Spam
* LIST (\HasNoChildren) "/" Trash
* LIST (\Noselect \HasChildren) "/" "Other Users"
T3 OK Completed (0.010 secs 28 calls)

@emersion
Copy link
Owner

Re-opening because this is just a workaround, it would be nice to investigate what exactly is going on.

@tomas-kucera
Copy link
Author

Re-opening because this is just a workaround, it would be nice to investigate what exactly is going on.

Let me know, if there is anything I can help with. I will.

BTW: I am aware that the Cyrus IMAP 2.5.10 is quite outdated (released Oct 2016). But it still does its job. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants