Skip to content

Mobile devices

Mail apps on phones and tablets set up corporate accounts through Exchange ActiveSync. One ActiveSync account synchronises mail, calendars, contacts and tasks, and the app keeps a request open to the server so that new mail arrives at once instead of at the next poll. With Exchange support enabled, Stalwart serves ActiveSync at /Microsoft-Server-ActiveSync, on the same HTTPS port as JMAP and the WebUI.

Stalwart offers ActiveSync versions 14.1 and 16.1, and the app chooses the version it uses among those that the server offers. Requests in versions 14.0 and 16.0 are accepted as well, but requests in older versions are answered with 400, so an app limited to them cannot connect.

Gmail and Nine on Android have been tested, Gmail over both versions and Nine over 16.1, for mail, calendar and contacts. The Thunderbird add-on TbSync has been tested for calendars, contacts and tasks. iOS Mail, Outlook for iOS and Android, and Samsung Email have not been tested.

Most apps offer an account type named Exchange, or Exchange and Office 365. The app first tries Autodiscover with the email address and password, and asks for the server settings when discovery fails. The settings to enter by hand are the following:

SettingValue
Email address and user nameThe account’s email address
PasswordThe account password, or an app password for accounts with two-factor authentication
ServerThe server’s host name, as in its public URL
Port and security443, SSL/TLS
DomainEmpty, or any value: the server ignores a DOMAIN\ prefix on the user name

On Android 7 and later, apps trust only the system’s certificate authorities by default, not those that the user installs on the device. The server therefore needs a certificate from a public authority, such as the one that ACME obtains, for Android devices to connect. Some apps offer to accept any certificate; that option disables the protection that TLS gives the password and the mail, and is no substitute for a valid certificate.

Each installation of an app that connects to an account registers itself as a device with an identifier of its own, on its first request; nothing has to be set up for it on the server. maxDevices limits how many devices one account may register, 16 by default. A device beyond the limit, when no registered device can be removed as described below, receives ActiveSync status 177 (maximum devices reached) and cannot synchronise.

A device stays registered after it stops connecting, so a user who replaces phones or reinstalls apps can reach the limit with devices no longer in use. The server frees room for a new device on its own. When an unknown device connects to an account that is already at the limit, the server removes the device that has gone longest without connecting, provided it has not connected for at least seven days, and deletes its synchronisation state. A device removed this way has to set up the account again if it comes back. When no device has been idle that long, the new device is refused as before, and the remedy is a higher maxDevices.

To learn of new mail without polling, the app sends a Ping request that the server holds open until something changes or the heartbeat interval ends, and then sends the next one. A longer interval means fewer requests and less battery use. maxHeartbeat is the longest interval the server accepts, 59 minutes by default, and the shortest is one minute. A Ping or Sync that asks for an interval outside these bounds receives a status that gives the allowed value. Firewalls, mobile networks and reverse proxies that close idle connections sooner cut the requests short and make the app reconnect more often, so any proxy in front of Stalwart needs a read timeout longer than the heartbeat.

Each waiting Ping or Sync counts towards the account’s limit of concurrent HTTP requests until it answers, and a device does not end its previous wait when it sends a new one. An account with several devices can therefore reach the limit, as described in Concurrent requests.

An Exchange server can impose security policies on devices, such as a passcode or storage encryption, and erase a lost device remotely. Stalwart does neither. It accepts devices that have not applied a policy, and when a device asks for one, it receives a policy that requires nothing. Remote wipe is not available. Devices that need such controls must be managed through a separate mobile device management system.

The following behaviours differ from an Exchange server:

  • Out of office uses one reply. The device can set separate replies for internal and external senders, but the server keeps one of them for every sender. A reply of 2 KiB or more is refused.
  • Name lookups return names and addresses only. Searches of the global address list return at most 100 entries, and carry no photos, telephone numbers, title or company. The office field carries a location only for rooms and equipment.
  • No document access. Shared document libraries (UNC paths and SharePoint) are not available.
  • Notes and journal folders cannot be created. Creating a mail, calendar, contacts or task folder works.
  • Send failures with unknown local recipients. A message to a recipient address on the server’s own domains that does not exist fails as a whole, with status 116 or 183, and no delivery report is generated.
  • Meeting forwards are copies. Forwarding a meeting sends an attached copy of the event, not an invitation, and the organizer is not notified.
  • Meeting replies carry no text. Accepting or declining a meeting sends the answer only, without a message or a proposal for a new time.
  • Duplicate-send protection is local. The server recognises a message that the device sends twice, for 24 hours, through the in-memory store. With the local in-memory store this protection is lost on restart and is not shared between cluster nodes, so a device that resends after a restart, or to another node, can send the message twice. A Stalwart Keep, Redis or sharded in-memory store keeps it across the cluster.

Differences from Exchange lists the remaining differences.