1:启动docker davmail
docker run -d 1143:1143 -p 1025:1025 -v /opt/apps/davmail/davmail.properties:/etc/davmail/davmail.properties jberrenberg/davmail
参数说明:
-p 1143:1143 IAMP端口
-p 1025:1025 SMTP端口
-v /opt/apps/davmail/davmail.properties:/etc/davmail/davmail.properties 本地配置文件映射到docker
davmail.properties 下载地址 https://raw.githubusercontent.com/mguessan/davmail/master/src/etc/davmail.properties
需要修改
davmail.mode=EWS
davmail.url=https://xxx/ews/Exchange.asmx
2:下载mailspring
https://getmailspring.com/download
3:配置邮箱
IMAP/SMPT
Email:xxx
Password:xxx
IMAP:
server:davmail 服务ip
port:davmail imap端口,例如:1413
Security:none
username:xxx @之前的
password:xxx
SMTP
同理
4:异常问题
在本机电脑正常,部署到服务器就不行了,会报如下错误
2018-12-29 09:03:34,796 ERROR [ImapConnection-53046] davmail - Authentication failed: invalid user or password, retry with domain\user or use default domain setting
davmail.exception.DavMailAuthenticationException: Authentication failed: invalid user or password, retry with domain\user or use default domain setting
at davmail.exchange.ExchangeSession.throwAuthenticationFailed(ExchangeSession.java:776)
at davmail.exchange.ExchangeSession.postLogonMethod(ExchangeSession.java:607)
at davmail.exchange.ExchangeSession.formLogin(ExchangeSession.java:677)
at davmail.exchange.ExchangeSession.<init>(ExchangeSession.java:247)
at davmail.exchange.dav.DavExchangeSession.<init>(DavExchangeSession.java:500)
at davmail.exchange.ExchangeSessionFactory.getInstance(ExchangeSessionFactory.java:191)
at davmail.exchange.ExchangeSessionFactory.getInstance(ExchangeSessionFactory.java:92)
at davmail.imap.ImapConnection.run(ImapConnection.java:112)
2018-12-29 09:03:34,802 INFO [ImapConnection-53046] davmail.connection -
经过查davmail.mode=OWA时,公司邮箱对于非办公网的owa访问,做了动态密码,必须输入正确的动态密码,才能认证通过,除了username password字段之外,还有一个token字段
后期把EWS模式访问,正常了
在github上提了一个issue,看后期作者能修改吗,自己尝试修改了,还是不行
https://github.com/mguessan/davmail/issues/17
还有一种情况,公司对访问的ip做限制,也会造成连接不上去,建议咨询下公司网管