Search code examples
c#imaphmail-serverimapx

ImapX can't login to local hMailServer from my application, but Thunderbird can


I have a local hMailServer instance, which I would like to connect to. I've successfully used ImapX for example for connecting to GMail or different mail servers, but simply cannot get the authentication work for this simple local hMailServer. I've spent about 2 hours now with it and tried quite everything.

If I try to log in with the same accoutn with Thunderbird, everything is fine. When my application tries to log in using ImapX, the server log show invalid username or password. Thunderbird is configureed for non-secure connection, using plain password, just as ImapX (I guess). Here are the logs, first with ImapX, second with Thunderbird.

With ImapX:

"IMAPD" 3268 3 "2014-12-21 00:32:05.098" "SENT: * OK IMAPrev1"
"IMAPD" 2180 3 "2014-12-21 00:32:05.114" "RECEIVED: IMAPX1 CAPABILITY"
"IMAPD" 2180 3 "2014-12-21 00:32:05.114" "SENT: * CAPABILITY IMAP4 IMAP4rev1 CHILDREN IDLE QUOTA SORT ACL NAMESPACE RIGHTS=texk[nl]IMAPX1 OK CAPABILITY completed"
"IMAPD" 3268 3 "2014-12-21 00:32:05.114" "RECEIVED: IMAPX2 LOGIN "[email protected]" ***"
"IMAPD" 3268 3 "2014-12-21 00:32:05.129" "SENT: IMAPX2 NO Invalid user name or password."

With Thunderbird:

"IMAPD" 3268 4 "2014-12-21 00:39:50.769" "SENT: * OK IMAPrev1"
"IMAPD" 3268 4 "2014-12-21 00:39:50.769" "RECEIVED: 1 capability"
"IMAPD" 3268 4 "2014-12-21 00:39:50.769" "SENT: * CAPABILITY IMAP4 IMAP4rev1 CHILDREN IDLE QUOTA SORT ACL NAMESPACE RIGHTS=texk[nl]1 OK CAPABILITY completed"
"IMAPD" 3268 4 "2014-12-21 00:39:50.769" "RECEIVED: 3 login "[email protected]" ***"
"IMAPD" 3268 4 "2014-12-21 00:39:50.769" "SENT: 3 OK LOGIN completed"
"IMAPD" 3268 4 "2014-12-21 00:39:50.769" "RECEIVED: 4 select "INBOX""

I've rechecked several times, that the exact same passwords are sent, no misspell or so. The only difference I see in the log is letter casing, but I doubt that has anything to do with it.

In my C# code I simply call _client.Login(userName, password), nothing special, no any non-default configuration for ImapX.

Has anyone any ideas what could cause this, or where else should I test something or have a look?


Solution

  • It turned out right after posting the question (as usual), that in the password which is stored in a database, I had ONE trailing space by accident. Because the password is removed from hMailServer log, I could not figure it out. After I called String.Trim before sending the login information, the login was succesful.

    Such a silly bug, I hope someone can benefit from this post in the future.