Prerequisite : Recent OpenJDK, version 8 or later supported.
Davmail Gateway can run in server mode as a gateway between the mail client and Exchange server through EWS or Graph (Exchange online only). In server mode Davmail can run on any platform provided Java OpenJDK is available. This mode was tested successfully with Iphone and Android phones and should work with any equipment with POP/IMAP/SMTP/LDAP/CalDAV/CardDAV clients. In this mode many users can share the same DavMail instance.
The following documentation describes how to run DavMail as a non root user. The DavMail Debian package and DavMail RPM package include systemd configuration to run DavMail as a service.
Download the noinstall package for Windows or platform independent DavMail package from Sourceforge and uncompress it with your favorite tool, e.g. on Linux: unzip davmail-*.zip.
Prepare a davmail.properties file according to your local needs (the most current version can be found here) :
# DavMail settings, see http://davmail.sourceforge.net/ for documentation
#############################################################
# Basic settings
# Server or workstation mode
davmail.server=false
# Gateway mode
# - O365EWS: Office 365 EWS mode
# - O365Graph: Office 365 Graph mode
# - ExchangeEWS: Exchange 2007 and later EWS mode
# - ExchangeWebDav: Exchange 2007 and earlier WebDav mode
davmail.mode=O365EWS
# Authentication mode:
# - O365Interactive Office 365 with interactive browser window, not available in headless mode (OpenJFX or SWT required)
# - O365Manual Office 365 with interactive dialog, not available in headless mode
# - O365DeviceCode Office 365 with device code flow
# - O365Transparent Office 365 transparent authentication, does not support all MFA factors
davmail.authentication=O365Interactive
# base Exchange OWA or EWS url
davmail.url=https://outlook.office365.com/EWS/Exchange.asmx
# optional: non-standard tenants
#davmail.tld=us
# login url, default https://login.microsoftonline.com, China https://login.chinacloudapi.cn
#davmail.loginUrl=https://login.microsoftonline.com
# Outlook O365 url, default https://outlook.office365.com, China https://partner.outlook.cn
#davmail.outlookUrl=https://outlook.office365.com
# Experimental: enable new Graph backend
# Enable both with DavMail clientId, leave Oidc disabled with Outlook clientId
#davmail.enableGraph=false
#davmail.enableOidc=false
# Listener ports
davmail.caldavPort=1080
davmail.imapPort=1143
davmail.ldapPort=1389
davmail.popPort=1110
davmail.smtpPort=1025
# Enable to override default DavMail Oauth configuration
#davmail.oauth.clientId=facd6cff-a294-4415-b59f-c5b01937d7bd
#davmail.oauth.redirectUri=https://localhost/common/oauth2/nativeclient
#davmail.oauth.tenantId=common
# On windows with SWT Webview2 embedded browser, allow using primary account single sign on
#davmail.oauth.allowSingleSignOnUsingOSPrimaryAccount=true
# Override OIDC scope
# graph endpoint scopes
#davmail.oauth.scope=openid profile offline_access Mail.ReadWrite Calendars.ReadWrite MailboxSettings.Read Mail.ReadWrite.Shared Contacts.ReadWrite Tasks.ReadWrite Mail.Send
# application default scopes
#davmail.oauth.scope=openid profile offline_access .default
# OIDC EWS scopes
#davmail.oauth.scope=openid profile offline_access https://outlook.office365.com/EWS.AccessAsUser.All
# Experimental: set origin header for SPA application clientId
#davmail.oauth.refreshTokenOrigin=https://outlook.office.com
# Override Graph url and version v1.0 or beta (default), see https://docs.microsoft.com/en-us/graph/api/overview?view=graph-rest-beta
#davmail.graphUrl=https://graph.microsoft.com
#davmail.graphPrefix=beta
# Optional: separate file to store Oauth tokens
#davmail.oauth.tokenFilePath=
#############################################################
# Network settings
# Network proxy settings
davmail.enableProxy=false
davmail.useSystemProxies=false
davmail.proxyHost=
davmail.proxyPort=
davmail.proxyUser=
davmail.proxyPassword=
# proxy exclude list
davmail.noProxyFor=
# allow remote connection to DavMail
davmail.allowRemote=true
# bind server sockets to a specific address
davmail.bindAddress=
# client connection timeout in seconds - default 300, 0 to disable
davmail.clientSoTimeout=
# DavMail listeners SSL configuration
davmail.ssl.keystoreType=
davmail.ssl.keystoreFile=
davmail.ssl.keystorePass=
davmail.ssl.keyPass=
# Accept specified certificate even if invalid according to trust store
davmail.server.certificate.hash=
# disable SSL for specified listeners
davmail.ssl.nosecurecaldav=false
davmail.ssl.nosecureimap=false
davmail.ssl.nosecureldap=false
davmail.ssl.nosecurepop=false
davmail.ssl.nosecuresmtp=false
# disable update check
davmail.disableUpdateCheck=true
# Send keepalive character during large folder and messages download
davmail.enableKeepAlive=true
# Message count limit on folder retrieval
davmail.folderSizeLimit=0
# Default windows domain for NTLM and basic authentication
davmail.defaultDomain=
#############################################################
# Caldav settings
# override default alarm sound
davmail.caldavAlarmSound=
# retrieve calendar events not older than 90 days
davmail.caldavPastDelay=90
# EWS only: enable server managed meeting notifications
davmail.caldavAutoSchedule=true
# WebDav only: force event update to trigger ActiveSync clients update
davmail.forceActiveSyncUpdate=false
# Disable VALARM section in calendar events
#davmail.caldavDisableReminders=false
# By default DavMail will retrieve default task folder items with default calendar events, can be disabled
#davmail.caldavDisableTasks=false
# Open a dialog to let user customize event accept/decline response
#davmail.caldavEditNotifications=true
# Deprecated: fetch legacy tasks over Webdav
#davmail.caldavEnableLegacyTasks=false
# Deprecated: delete broken events over Webdav
#davmail.deleteBroken=false
# Experimental: impersonate shared calendar identity
#davmail.caldavImpersonate=false
# Enable or disable contact photo support
#davmail.carddavReadPhoto=true
# exclude shared calendars private events
#davmail.excludePrivateEvents=false
# Override mailbox defined timezone id
#davmail.timezoneId=UTC
# ignore none match on calendar event create or update
#davmail.ignoreNoneMatchStar=true
# Automatically create a Teams online meeting
#davmail.caldav.enableOnlineMeeting=true
#############################################################
# IMAP settings
# Delete messages immediately on IMAP STORE \Deleted flag
davmail.imapAutoExpunge=true
# To enable IDLE support, set a maximum client polling delay in minutes
# Clients using IDLE should poll more frequently than this delay
davmail.imapIdleDelay=
# Always reply to IMAP RFC822.SIZE requests with Exchange approximate message size for performance reasons
davmail.imapAlwaysApproxMsgSize=
# custom IMAP flags, see https://davmail.sourceforge.net/thunderbirdmailsetup.html
# davmail.imapFlags.$label2=Hobby
# davmail.imapFlags.some_test_tag=Some test Category
# Enable chunked request to send large mail, may not work with on prem Exchange
#davmail.enableChunkedRequest=false
# Override folder paging fetch size
#davmail.folderFetchPageSize=500
#############################################################
# POP settings
# Delete messages on server after 30 days
davmail.keepDelay=30
# Delete messages in server sent folder after 90 days
davmail.sentKeepDelay=90
# Mark retrieved messages read on server
davmail.popMarkReadOnRetr=false
#############################################################
# SMTP settings
# let Exchange save a copy of sent messages in Sent folder
davmail.smtpSaveInSent=true
# SMTP remove From header to force send as connected user
#davmail.smtpStripFrom=false
# SMTP allow sending multiple messages with the same message id
#davmail.smtpAllowDuplicateSend=false
#############################################################
# Loggings settings
# log file path, leave empty for default path
davmail.logFilePath=/var/log/davmail.log
# maximum log file size, use Log4J syntax, set to 0 to use an external rotation mechanism, e.g. logrotate
davmail.logFileSize=1MB
# log levels
log4j.logger.davmail=DEBUG
log4j.logger.httpclient.wire=WARN
log4j.logger.httpclient=WARN
log4j.rootLogger=WARN
#############################################################
# Workstation only settings
# smartcard access settings
davmail.ssl.pkcs11Config=
davmail.ssl.pkcs11Library=
# SSL settings for mutual authentication
davmail.ssl.clientKeystoreType=
davmail.ssl.clientKeystoreFile=
davmail.ssl.clientKeystorePass=
# require client certificate
#davmail.ssl.needClientAuth=false
# Override default JDK truststore
#davmail.ssl.truststoreFile=cacerts
#davmail.ssl.truststorePass=changeit
#davmail.ssl.truststoreType=JKS
# enable tray icon
#davmail.enableTray=false
# disable all balloon notifications
davmail.disableGuiNotifications=false
# disable tray icon color switch on activity
davmail.disableTrayActivitySwitch=false
# disable startup balloon notifications
davmail.showStartupBanner=true
# Override tray background or force grayscale in tray icon to match desktop theme
#davmail.trayBackgroundColor=\#DDF6E8
#davmail.trayGrayscale=false
#############################################################
# Authentication
# Provide a custom authenticator class
#davmail.authenticator=davmail.exchange.auth.O365InteractiveAuthenticator
# Use JCIFS NTLM implementation
#davmail.enableJcifs=true
# enable transparent client Kerberos authentication
davmail.enableKerberos=false
#############################################################
# Debug/Advanced
# Deprecated, use davmail.mode instead
#davmail.enableEws=true
# Disable Gzip encoding to have clear text wire logging http response body
#davmail.acceptEncodingGzip=true
# Dump calendar events to local files
#davmail.dumpICS=0
# Custom http client timeouts
#davmail.exchange.connectionTimeout=10
#davmail.exchange.soTimeout=120
# Override http client max redirect
#davmail.httpMaxRedirects=10
# Override default Oauth token encryption fingerprint
#davmail.oauth.fingerprint=MyCustomFingerPrint
# Disable persist token to file (force reauthentication)
#davmail.oauth.persistToken=true
# Deprecated swith deleted MAPI property
#davmail.popCommonDeleted=true
# EWS: retrieve all folders including special
#davmail.imapIncludeSpecialFolders=false
# User allow list, comma separated list of values, \@company.com means all domain users are allowed
#davmail.userWhiteList=\@company.com
# O365InteractiveAuthenticator enable page content logging with embedded OpenJFX browser
#davmail.webview.debug=false
# Exit DavMail on bind failure
#davmail.exitOnBindFailed=false
See Getting started for more information on the options. Make sure davmail.server is set to true (no icon tray) and allow remote connections: davmail.allowRemote=true.
To disable a listener, set an empty port value.
Launch Davmail with the following command:
nohup davmail davmail.properties &
Then check messages:
tail -f nohup.out
A new WinRun4J davmailservice.exe wrapper is available in the windows package. Preferred package is the standalone windows package that comes with Zulu JDK.
To register DavMail as a windows service, use:
davmailservice64 --WinRun4J:RegisterService
sc create DavMail binPath= \path\to\davmailservice64.exe type= own start= auto
If you get [err] Could not access service manager: 5 message make sure you open command line in administrator mode first and run command again. On first start service will create a default davmail.properties file in DavMail directory, note that this is different from user mode where .davmail.properties is located in user home directory. Adjust this configuration to your requirements and restart DavMail.
To launch DavMail on OSX with LaunchDaemon, you may try the following user provided script:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>davmail</string>
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/usr/libexec/davmail/davmail</string>
<string>/usr/libexec/davmail/davmail.properties</string>
</array>
</dict>
</plist>