How JMAP tells apps about new mail
A JMAP server never sends the new mail itself. It sends a short notice that something changed, and the app then asks for just the changes. There are three ways to get that notice.
| Way | How it works | Best for |
|---|---|---|
| EventSource | The app keeps one https connection open and the server writes a line when something changes | Desktop and web apps that stay open |
| Web Push | The server posts the notice to an address the app gave it, even when the app is closed | Phone apps and browsers |
| WebSocket (RFC 8887) | Requests and notices share one open connection | Busy apps that send lots of requests |
Why phones are different
iPhones and Android phones close apps in the background, so an open connection doesn't last. Instead, the app gives the server a Web Push address, often a small relay run by the app's maker, which turns the notice into a normal phone alert. The notice only says "something changed", and servers can encrypt it, so the relay never sees your mail.
Does my server support it?
Run the checker with a token. It shows whether the session offers EventSource, Web Push and WebSocket.
What the notice looks like
Whichever way it arrives, the notice is the same small piece of JSON, called a StateChange. It lists each account that changed and, for each kind of data, its new state string:
{
"@type": "StateChange",
"changed": {
"A1": {
"Email": "d35ecb040aab",
"Mailbox": "0af7a512ce70",
"Thread": "29fe2e7b1d54"
}
}
}The app compares each state with the one it saved last time. If Email has moved on, it calls Email/changes with its old state and gets back only the ids that were created, updated or destroyed. Nothing in the notice says who the mail is from or what it's about.
How a server says which ways it offers
| Way | Where to look in the session | What the app does |
|---|---|---|
| EventSource | eventSourceUrl, a link template with {types}, {closeafter} and {ping} to fill in | Opens the link and keeps it open. ping asks the server to send a heartbeat so the app can tell a quiet connection from a dead one |
| Web Push | Part of the core standard (RFC 8620), so there's nothing extra to look for | Calls PushSubscription/set with its push address. The server first sends a one off code, which the app sends back to prove the address is really its own |
| WebSocket | The urn:ietf:params:jmap:websocket capability, with a url and supportsPush | Connects to that address, then sends WebSocketPushEnable to start getting notices on the same connection |
Web Push is in the core standard, but not every server supports all three ways in practice, so check yours with the checker. The capabilities reference covers the WebSocket and Web Push keys capabilities too.
Going further
- Push in practice covers the settings that matter and what to do after a gap, such as a phone that was offline.
- The push tester connects to your server's EventSource feed so you can watch notices arrive live.
- The Who supports JMAP table shows which providers and servers offer new mail alerts.