davmail
davmail copied to clipboard
Emacs mu4e + mbsync + davmail
Expected or desired behavior
Make exchange works with mu4e (via davmail)
Actual behavior
Hello,
I have read the documentation correctly but I still have difficulties to successfully identify my business email via davmail.
The configuration of my.mbsynrc is as follows:
IMAPAccount Work
Host localhost
Port 1143
AuthMechs LOGIN
User domain\\user.name
UseIMAPS no
RequireSSL no
UseTLSv1 no
Pass MYPASSWORD
IMAPStore Work-remote
Account Work
MaildirStore Work-local
Path ~/Maildir/Work/
Inbox ~/Maildir/Work/INBOX
Channel Work
Master :Work-remote:
Slave :Work-local:
Create Slave
Sync Pull
SyncState *
I get the following error message (in terminal) :
[12:03:34] ~ : mbsync Work
Notice: IMAP account 'Work': UseSSL*, UseTLS*, UseIMAPS, and RequireSSL are deprecated. Use SSLType and SSLVersions instead.
C: 0/1 B: 0/1 M: +0/0 *0/0 #0/0 S: +0/0 *0/0 #0/0
*** IMAP Warning *** Password is being sent in the clear
IMAP command 'LOGIN <user> <pass>' returned an error: NO LOGIN failed
C: 1/1 B: 0/1 M: +0/0 *0/0 #0/0 S: +0/0 *0/0 #0/0
I tried to change "user" to "user.name" (without the domain) but it doesn't work.
I don't understand what I'm doing wrong. Do you have any idea? Thank you in advance.
I have tried with LOGIN
domain\\user.name
domain\user.name
user.name
But nothing works. Maybe i need to configure something in davmail ?
Please first check DavMail configuration by accessing Caldav in a web browser. If your client does not like domain\username syntax, please set default domain in DavMail settings
Yes it seems to work.

When davmail run, i can access to the webmail in firefox.
Which credentials do you use to access https://localhost:1080 ?
=> you will have to use the same credentials on the client side
Hi, thanks for reply. I have an SSL error

Sorry, default config without certificate: http://localhost:1080
I do have a dialog box to enter the login and password but I can't login...
With classic webmail I sometimes have a connection problem. I have to empty the cookies to make it work. Could I have a problem like that?

I'm still stuck. Maybe they closed some ports? But if I have the identification window below it's a pretty good sign, right @mguessan ?

Well, this means you can access DavMail.
=> Next steps:
- check authentication directly to Exchange
- check authentication through DavMail
- check davmail.log for errors.
=> No need to try with your IMAP client until you make both work.
Hi, Thank for reply. Authentification directly to exchange by webmail is OK. Through Davmail, i have those errors :
2019-11-02 13:23:09,273 INFO [davmail.caldav.CaldavServer] davmail.connection - DISCONNECT - 127.0.0.1:49692
2019-11-02 13:23:09,274 DEBUG [CaldavConnection-49692] davmail - Connection closed
2019-11-02 13:23:09,276 INFO [CaldavConnection-49692] davmail.connection - DISCONNECT - 127.0.0.1:49692
2019-11-02 13:23:09,291 INFO [AWT-EventQueue-0] davmail - DavMail Gateway 5.3.1-trunk listening on SMTP port 1025 IMAP port 1143 CALDAV port 1080
2019-11-02 13:23:09,641 DEBUG [CheckRelease] davmail.DavGateway - DavMail released version: 5.3.1-3079
2019-11-02 13:23:25,056 DEBUG [davmail.caldav.CaldavServer] davmail - Connection from /127.0.0.1 on port 1080
2019-11-02 13:23:25,062 INFO [davmail.caldav.CaldavServer] davmail.connection - CONNECT - 127.0.0.1:49720
2019-11-02 13:23:25,064 DEBUG [CaldavConnection-49720] davmail - < GET / HTTP/1.1
2019-11-02 13:23:25,065 DEBUG [CaldavConnection-49720] davmail - < Host: localhost:1080
2019-11-02 13:23:25,066 DEBUG [CaldavConnection-49720] davmail - < User-Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0
2019-11-02 13:23:25,067 DEBUG [CaldavConnection-49720] davmail - < Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
2019-11-02 13:23:25,067 DEBUG [CaldavConnection-49720] davmail - < Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.5,en;q=0.3
2019-11-02 13:23:25,068 DEBUG [CaldavConnection-49720] davmail - < Accept-Encoding: gzip, deflate
2019-11-02 13:23:25,068 DEBUG [CaldavConnection-49720] davmail - < DNT: 1
2019-11-02 13:23:25,068 DEBUG [CaldavConnection-49720] davmail - < Connection: keep-alive
2019-11-02 13:23:25,069 DEBUG [CaldavConnection-49720] davmail - < Upgrade-Insecure-Requests: 1
2019-11-02 13:23:25,069 DEBUG [CaldavConnection-49720] davmail - < Authorization: ********
2019-11-02 13:23:25,207 DEBUG [CaldavConnection-49720] davmail - executeFollowRedirects(https://messagerie.social.gouv.fr/owa/)
2019-11-02 13:23:25,248 DEBUG [CaldavConnection-49720] davmail - executeFollowRedirects: /my.policy redirectCount:1
2019-11-02 13:23:25,311 DEBUG [CaldavConnection-49720] davmail.exchange.auth.ExchangeFormAuthenticator - Form based authentication detected
2019-11-02 13:23:25,321 DEBUG [CaldavConnection-49720] davmail.exchange.auth.ExchangeFormAuthenticator - Authentication form not found at /my.policy, trying default url
2019-11-02 13:23:25,322 DEBUG [CaldavConnection-49720] davmail - executeFollowRedirects(/owa/auth/owaauth.dll)
2019-11-02 13:23:25,356 ERROR [CaldavConnection-49720] davmail.exchange.auth.ExchangeFormAuthenticator - Authentication failed: invalid user or password, retry with domain\user or use default domain setting
2019-11-02 13:23:25,356 INFO [CaldavConnection-49720] davmail.connection - FAILED - 127.0.0.1:49720 MY.NAME
2019-11-02 13:23:25,356 DEBUG [CaldavConnection-49720] davmail - > HTTP/1.1 401 Unauthorized
2019-11-02 13:23:25,356 DEBUG [CaldavConnection-49720] davmail - > WWW-Authenticate: Basic realm="Passerelle DavMail"
2019-11-02 13:23:25,356 DEBUG [CaldavConnection-49720] davmail - > Connection: keep-alive
2019-11-02 13:23:25,356 DEBUG [CaldavConnection-49720] davmail - > Content-Length: 0
2019-11-02 13:23:25,357 DEBUG [CaldavConnection-49720] davmail - >
And davmail config like this :

And a precision, I can connect via thunderbird (Chouette module) on another machine. So it must be possible ;-)
Please try in EWS mode with the following url: https://messagerie.social.gouv.fr/EWS/Exchange.asmx
Ok thanks, the new error message is
019-11-03 10:12:43,633 DEBUG [CaldavConnection-49726] davmail - < GET / HTTP/1.1
2019-11-03 10:12:43,640 DEBUG [CaldavConnection-49726] davmail - < Host: localhost:1080
2019-11-03 10:12:43,641 DEBUG [CaldavConnection-49726] davmail - < User-Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0
2019-11-03 10:12:43,643 DEBUG [CaldavConnection-49726] davmail - < Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
2019-11-03 10:12:43,644 DEBUG [CaldavConnection-49726] davmail - < Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.5,en;q=0.3
2019-11-03 10:12:43,646 DEBUG [CaldavConnection-49726] davmail - < Accept-Encoding: gzip, deflate
2019-11-03 10:12:43,646 DEBUG [CaldavConnection-49726] davmail - < DNT: 1
2019-11-03 10:12:43,647 DEBUG [CaldavConnection-49726] davmail - < Connection: keep-alive
2019-11-03 10:12:43,648 DEBUG [CaldavConnection-49726] davmail - < Upgrade-Insecure-Requests: 1
2019-11-03 10:12:43,649 DEBUG [CaldavConnection-49726] davmail - < Authorization: ********
2019-11-03 10:12:43,651 DEBUG [CaldavConnection-49726] davmail.http.DavGatewayHttpClientFacade - get Default proxy selector
2019-11-03 10:12:43,651 DEBUG [CaldavConnection-49726] davmail.http.DavGatewayHttpClientFacade - getProxyForURI(https://messagerie.social.gouv.fr/EWS/Exchange.asmx)
2019-11-03 10:12:43,652 DEBUG [CaldavConnection-49726] davmail.http.DavGatewayProxySelector - Selected [DIRECT] proxy for https://messagerie.social.gouv.fr/EWS/Exchange.asmx
2019-11-03 10:12:43,652 DEBUG [CaldavConnection-49726] davmail.http.DavGatewayProxySelector - Selected [DIRECT] proxy for https://messagerie.social.gouv.fr/EWS/Exchange.asmx
2019-11-03 10:12:43,653 DEBUG [CaldavConnection-49726] davmail.http.DavGatewayHttpClientFacade - got system proxies:[DIRECT]
2019-11-03 10:12:43,760 DEBUG [CaldavConnection-49726] davmail - executeFollowRedirects(https://messagerie.social.gouv.fr/EWS/Exchange.asmx)
2019-11-03 10:12:44,361 WARN [CaldavConnection-49726] org.apache.commons.httpclient.HttpMethodBase - Cookie rejected: "$Version=0; TS01092e1b=012337f68dc912f62e3f79a1cc0e9fbba9bf3f5455b87fbc72f85b3392a4a409c638ac3061ba8e5d0693caef66fd84bdabc69751479b49667e4a6c7d55765b9240395bf619; $Path=/; $Domain=.messagerie.social.gouv.fr". Illegal domain attribute ".messagerie.social.gouv.fr". Domain of origin: "messagerie.social.gouv.fr"
2019-11-03 10:12:44,362 ERROR [CaldavConnection-49726] org.apache.commons.httpclient.HttpMethodDirector - basic authorization challenge expected, but not found
org.apache.commons.httpclient.auth.AuthenticationException: basic authorization challenge expected, but not found
at org.apache.commons.httpclient.auth.AuthChallengeProcessor.processChallenge(AuthChallengeProcessor.java:159)
at org.apache.commons.httpclient.HttpMethodDirector.processWWWAuthChallenge(HttpMethodDirector.java:694)
at org.apache.commons.httpclient.HttpMethodDirector.processAuthenticationResponse(HttpMethodDirector.java:668)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:193)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
at davmail.http.DavGatewayHttpClientFacade.executeMethod(DavGatewayHttpClientFacade.java:353)
at davmail.http.DavGatewayHttpClientFacade.executeFollowRedirects(DavGatewayHttpClientFacade.java:420)
at davmail.http.DavGatewayHttpClientFacade.executeFollowRedirects(DavGatewayHttpClientFacade.java:349)
at davmail.exchange.auth.ExchangeFormAuthenticator.authenticate(ExchangeFormAuthenticator.java:194)
at davmail.exchange.ExchangeSessionFactory.getInstance(ExchangeSessionFactory.java:207)
at davmail.exchange.ExchangeSessionFactory.getInstance(ExchangeSessionFactory.java:97)
at davmail.caldav.CaldavConnection.run(CaldavConnection.java:176)
2019-11-03 10:12:44,366 ERROR [CaldavConnection-49726] davmail.exchange.auth.ExchangeFormAuthenticator - Authentication failed: invalid user or password
2019-11-03 10:12:44,367 INFO [CaldavConnection-49726] davmail.connection - FAILED - 0:0:0:0:0:0:0:1:49726 MY.NAME
2019-11-03 10:12:44,367 DEBUG [CaldavConnection-49726] davmail - > HTTP/1.1 401 Unauthorized
2019-11-03 10:12:44,369 DEBUG [CaldavConnection-49726] davmail - > WWW-Authenticate: Basic realm="Passerelle DavMail"
2019-11-03 10:12:44,370 DEBUG [CaldavConnection-49726] davmail - > Connection: keep-alive
2019-11-03 10:12:44,370 DEBUG [CaldavConnection-49726] davmail - > Content-Length: 0
2019-11-03 10:12:44,371 DEBUG [CaldavConnection-49726] davmail - >
Seems to be a cookie problem ?
To complete, here are some screenshots of my configuration.

Same message when i try to change "auto" for "EWS" in davmail config...
This cookie problem would be consistent with the behavior of webmail. I "often" have to type my password several times or delete the cookie in my browser to make a successful connection. What do you think about this situation @mguessan ?
We are not supposed to have cookies over EWS, however we do see a Cookie rejected message in your log... this may be an issue.
Anyway, it would be interesting to have a log of a successful authentication in a web browser (F12+network)
Ok. Identification in web browser looks like this

What information do you need in more detail?
Hi, Based on the latest figures of your configuration can you try to: change the protocole exchange to EWS (not AUTO); leave network, encryption and logging empty. Note: I also have ports for POP (1110) and LDAP (1389) on but that shouldn't make a difference. Let me know if anything improves.
Yes i have test it but nothing work at this time. Same problem, same error message with EWS. :thinking:
This is the configuration that I am using at the moment

Ok, thanks.
@bepolymathe your browser screenshot contain an OWA authentication, not EWS, which is et /EWS/Exchange.asmx
You can then export requests as a har file. Please do not post it publicly and send it to my private email address [email protected]
@mguessan Ok. I send you an email.
Can you please provide a status update on this ?
It's always the same problem. I can't make a positive I.D. I've tried dozens of configurations... without success.
If davmail seems to be working fine, then it is something between mbsync and davmail. Can you run mbsync with the verbose option -V and post the output? I had a login error just as yours and it was because of special characters in the password, that mbsync was unable to pass to davmail. I know you said that you already tried removing special characters and it didn't work, but just to make sure, you left only letters or numbers right?
@averter No, the problem is upstream. I can't find the right I.D. with the pro server... "name", "\domain\name", etc...