DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
VGSources
Blog

How to Set Up a DavMail Exchange Gateway on a Linux VPS

A practical guide to installing and securing DavMail on a Linux VPS, including backend selection, device-code OAuth, sample ports, systemd service setup and troubleshooting.
Length11 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To run DavMail headlessly on a Linux VPS, install a recent OpenJDK and DavMail, create a server-mode properties file, authenticate Microsoft 365 with a non-interactive method such as device code, and run the gateway as a dedicated non-root systemd service. Open only the protocol listeners your clients need—sample ports are IMAP 1143, POP 1110, SMTP 1025, CalDAV/CardDAV 1080, and LDAP 1389—and protect the OAuth token and configuration files like passwords.

What DavMail does on a VPS

DavMail is a protocol gateway, not a replacement mail server. It connects upstream to Microsoft Exchange or Microsoft 365 and exposes conventional client protocols: POP and IMAP for mail retrieval, SMTP for sending, CalDAV for calendars, CardDAV for contacts, and LDAP for directory lookups. A desktop or mobile client can therefore use standard account settings even when the upstream service expects Exchange Web Services (EWS), Microsoft Graph, or an older Exchange WebDAV deployment.

As an Amazon Associate I earn from qualifying purchases.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

On a VPS, the gateway is normally always on. Your mail, calendar, and contacts applications connect to the VPS hostname; DavMail maintains the authenticated connection to the Exchange mailbox. The VPS must be able to reach the selected Exchange endpoint, while clients must be able to reach each listener you intentionally enable.

Choose the backend and authentication before installing

The properties file must match both the mailbox type and the tenant’s current authentication policy. DavMail’s documented modes include Microsoft 365 through EWS (O365EWS), Microsoft 365 through Graph (O365Graph), on-premises Exchange through EWS (ExchangeEWS), and older Exchange WebDAV (ExchangeWebDav).

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.
Decision Use when Important qualification
Microsoft 365 or on-premises Exchange Microsoft 365 mailboxes generally use the O365 modes; an organization-hosted Exchange server uses an Exchange mode. The correct OWA/EWS URL and tenant policy determine whether a mode works.
EWS or Graph Select the backend supported by your DavMail release and the tenant. Do not assume an endpoint or API is enabled; verify it with the Exchange administrator.
Device-code OAuth Best fit for a VPS with no graphical browser. The tenant and DavMail version must support the device-code flow.
Interactive or manual OAuth Only when an approved browser or dialog is available during authorization. O365Interactive and O365Manual are documented as unavailable in truly headless mode.
Package installation You want distribution integration and the packaged systemd service. The repository’s DavMail version may lag behind the newest release.
Platform-independent archive You need a newer release than your distribution provides. You must manage the launcher, upgrades, and service integration yourself.

For a current Microsoft 365 deployment, start with the tenant’s supported backend rather than copying an old configuration. For on-premises Exchange, obtain the OWA/EWS base URL for that specific Exchange version and deployment; older WebDAV installations require the corresponding legacy mode.

Prepare the Linux VPS

Operating system, DNS, and account

  • Use a currently supported Linux distribution and apply its security updates.
  • Give the VPS a stable DNS name if remote clients will connect to it. Clients should use that name consistently when you later add certificates or firewall rules.
  • Create a dedicated service account for DavMail. Do not run the gateway as root.
  • Record the VPS firewall and cloud-provider firewall separately; both layers must permit the same intended client sources.

Install Java

DavMail requires OpenJDK. The server documentation supports OpenJDK 8 or later; a recent distribution-supported OpenJDK is preferable for a new deployment. Install it with your distribution package manager and verify the runtime before installing DavMail:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
java -version

The output should identify OpenJDK and a supported version. If several Java runtimes are installed, make sure the account that starts DavMail resolves the intended binary.

Install DavMail: package or archive

Distribution package

Use the Debian or RPM package when you want the maintainer-provided files, upgrades through the operating system, and the supplied systemd integration. After installation, inspect the installed unit rather than creating a competing service:

systemctl cat davmail
systemctl status davmail

The exact package name and executable location depend on the distribution. Use the package’s own unit and paths as the authoritative values on that host.

Platform-independent archive

Use the platform-independent distribution when the repository version is too old for your tenant or when you need a release not packaged by the distribution. Unpack it below a root-owned application directory such as /opt/davmail. Keep the application files non-writable by the service account where practical, while placing the writable properties and OAuth token in a protected directory owned by that account.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed

Do not mix files from different releases. Record the archive version, test the Java launcher manually as the service account, and then point a custom systemd unit at that tested launcher. If you later switch to a distribution package, remove or disable the archive-based unit so two gateways cannot bind the same ports.

Create the server-mode properties file

Create a file readable only by the DavMail service account. This example uses Microsoft 365 through EWS and the documented sample listeners:

davmail.server=true
davmail.mode=O365EWS
davmail.authentication=O365DeviceCode
davmail.url=https://outlook.office365.com/EWS/Exchange.asmx
davmail.imapPort=1143
davmail.popPort=1110
davmail.smtpPort=1025
davmail.caldavPort=1080
davmail.ldapPort=1389

Set davmail.mode to the backend appropriate for the mailbox. Microsoft 365 may use O365Graph instead of O365EWS when that is the supported choice. An on-premises server normally uses ExchangeEWS with its own URL, or ExchangeWebDav for an older WebDAV deployment. Do not leave the Microsoft 365 URL in place for an on-premises mailbox.

The five port values are examples, not mandatory numbers. They are deliberately above the traditional privileged-port range, which lets a non-root process bind them. Change a port only when another service already uses it or your client policy requires a different value, and then use the changed value consistently in firewall and client settings.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Disable protocols you will not use. For example, a mail-only installation can omit POP, CalDAV, and LDAP listeners rather than exposing unnecessary services. Keep the file’s ownership and mode restrictive because it identifies the gateway’s behavior and may be accompanied by OAuth material.

Authenticate Microsoft 365 without a desktop browser

Use device code for a headless first run

A VPS normally has no graphical session, so choose O365DeviceCode when the tenant and installed DavMail version support it. The first authorization presents a device code that you complete from an already approved browser on another device. Follow the code and consent instructions printed by DavMail, then allow the process to finish and save its token data.

Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

Run this initial authorization as the same non-root account that systemd will use. Otherwise the token can be written into root’s home directory and the service account will fail to find it later. Confirm the token file’s location, ownership, and permissions before starting the permanent service.

Why interactive and manual modes fail on a VPS

O365Interactive expects an interactive browser window, and O365Manual expects an interactive dialog or browser-assisted process. The server configuration reference marks both as unavailable in headless mode. A missing login window is therefore expected behavior, not evidence that the VPS firewall is blocking authentication. Replace the mode with a headless-capable method or perform an approved initial authorization workflow elsewhere and securely transfer the resulting token for the service account.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Consent, tenant IDs, and redirect URI changes

Microsoft 365 may require user consent on first use. Organizations that restrict consent can require an administrator to approve the application or provide a tenant ID and custom client ID according to their policy. The DavMail FAQ documents a January 2026 redirect-URI change to https://localhost/common/oauth2/nativeclient. If authorization reports a redirect mismatch, compare the registered redirect URI, tenant settings, client ID, and DavMail version with that current requirement instead of reusing an older registration.

Treat the token as a credential. Store it outside publicly served directories, restrict it to the service account, include it in encrypted backups only, and revoke or replace it if the VPS or backup is exposed.

Run DavMail with systemd

Prefer the packaged unit

Debian and RPM packages include systemd configuration. Enable that unit after placing the properties file where the package expects it, then check its effective command and environment:

sudo systemctl daemon-reload
sudo systemctl enable --now davmail
sudo systemctl status davmail
sudo journalctl -u davmail -f

If the unit references a different properties path, either put the file there or use the distribution’s documented override mechanism. Do not edit a generated unit directly if package upgrades may replace it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

Build a unit for an archive installation

An archive deployment needs an equivalent unit. Use the actual Java launcher and properties path you tested manually; the following illustrates the required behavior rather than asserting a universal archive filename:

[Unit]
Description=DavMail Exchange gateway
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=davmail
Group=davmail
ExecStart=/usr/bin/davmail /etc/davmail.properties
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

Place the unit in the systemd unit directory, reload systemd, enable it at boot, and inspect the journal. If your archive requires a Java command rather than a distribution launcher, replace ExecStart with the tested archive command and keep the non-root user, restart policy, and properties path. Protect the properties file with ownership and permissions that allow this account to read it but do not grant general users access.

Use systemctl status and journalctl -u davmail as the first diagnostics. A restart loop usually indicates a malformed properties file, an unavailable Java runtime, a missing token, or a port collision; the journal normally identifies which one.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Bind listeners and lock down the firewall

Service Sample port Client use
IMAP 1143 Folder listing and message synchronization.
POP 1110 Mailbox retrieval for clients that use POP.
SMTP 1025 Message submission through DavMail.
CalDAV/CardDAV 1080 Calendar and contact access.
LDAP 1389 Directory and address-book lookups.

These are the documented sample listener ports. Confirm the active values in your properties file and with ss -ltnp after startup. If a port is already occupied, stop the conflicting service or choose another unprivileged port and update every dependent rule.

Bind listeners to localhost when all clients run on the VPS. If remote clients must connect, restrict the VPS and cloud firewall to known source addresses or a private network. Open only the protocols in use. Do not publish an unauthenticated listener to the public internet. Apply the TLS and certificate settings supported by your DavMail version when traffic leaves the host; a firewall rule alone does not encrypt credentials or mail.

Keep outbound access to the Microsoft 365 or Exchange endpoint available. In addition to the host firewall, check provider policies that may restrict outbound mail traffic; the gateway still needs to reach its upstream service even when inbound listeners are tightly restricted.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

Connect clients and verify each protocol separately

Use the VPS DNS name, the enabled listener’s port, and the mailbox credentials or OAuth-backed login expected by your DavMail version. Configure only the services you enabled; a client should not be pointed at the SMTP port for IMAP or at the LDAP port for calendar access.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Test IMAP by authenticating and listing folders. Confirm that the inbox and expected folders appear.
  2. Test SMTP by sending a message to a controlled recipient, then verify delivery and the sent-message behavior.
  3. If POP is required, retrieve a test message and confirm the client’s leave-on-server policy.
  4. For CalDAV, read an existing calendar and create a disposable event, then verify the change upstream.
  5. For CardDAV or LDAP, perform a contact or directory lookup and confirm the expected address data.
  6. Watch journalctl -u davmail while each test runs. This separates an authentication problem from a blocked listener or a backend error.

The protocol surface is broad, but success is not all-or-nothing: mail may work while calendar or directory access fails because those listeners, client URLs, or permissions are configured independently.

Troubleshoot the common failure branches

No login window appears

That is expected when an interactive authentication mode is used on a headless VPS. Switch to O365DeviceCode where supported, or complete an approved interactive authorization and securely persist the resulting token for the service account.

OAuth consent or redirect errors

Check whether the tenant requires administrator consent, whether the tenant ID and client ID are correct, and whether the redirect URI matches the current registration. For registrations affected by the January 2026 change, use https://localhost/common/oauth2/nativeclient. Also verify that the token belongs to the same service account that starts DavMail.

Clients receive “connection refused”

  • Confirm the listener is enabled in the properties file.
  • Check the service state and journal for a startup failure.
  • Run ss -ltnp to verify that DavMail is listening on the expected address and port.
  • Check both the VPS firewall and the cloud firewall for the client’s source address.
  • Look for another process already using the port.

The gateway reaches the wrong Exchange server

Verify whether the mailbox is Microsoft 365, Exchange 2007 or later on premises, or an older WebDAV installation. Then confirm the OWA/EWS base URL and select the matching mode. The Microsoft 365 example URL is https://outlook.office365.com/EWS/Exchange.asmx; it is not a universal endpoint for on-premises deployments.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Sent messages appear twice

The DavMail FAQ warns that duplication can occur when an IMAP client stores a copy in Sent while Exchange also saves the submitted message. Configure the client so only one side performs the Sent-folder save, then send a new test message to confirm the change.

The service works manually but not at boot

Compare the interactive and systemd environments. The unit may use a different user, Java binary, working directory, properties path, or token location. Run the launcher as the service account, make the token readable only by that account, and inspect the unit with systemctl cat davmail before changing firewall rules.

Operate the gateway safely

  • Keep DavMail, OpenJDK, and the Linux distribution patched. Test upgrades with a copy of the properties and token permissions before scheduling a production restart.
  • Back up the properties file and OAuth token only in encrypted storage. A token backup should be handled as a password-equivalent secret.
  • Review listening sockets after every configuration change and remove protocols no client uses.
  • Limit administrative access to the VPS, and do not place the properties or token under a web server’s document root.
  • Monitor systemd restarts and authentication failures. A sudden increase can indicate an expired token, a tenant policy change, or an attempted connection from an unintended source.
  • Document the backend, Exchange URL, listener ports, service account, and OAuth registration details so a replacement VPS can be rebuilt without guessing.

With the gateway running as a non-root systemd service, headless OAuth completed, and only required listeners reachable, a Linux VPS can provide stable standard-protocol access to an Exchange or Microsoft 365 mailbox without a desktop session.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.