Please don’t bother for now. The bot makes a good point. I will have to confirm this before anyone wastes any time on it.
The original description was:
Issue Description
I run my own Stalwart server and I am writing my own small mail app for my iPhone and my Mac, for myself only, at least so far. It’s coming along nicely, and maybe I’ll open source it or publish it in the stores.
The app leans on push: the server pushes new mail to my phone through Apple’s notification service, and because emailpush carries the sender, subject and a preview inside the notification itself, the phone can show me what arrived without fetching anything. On iOS, the app cannot run in the background because of the operating system.
What goes wrong is that my phone also notifies me when nothing has arrived. Marking a message as read on my Mac makes my phone show “New mail”. Those are StateChange notifications — a general “something changed in your account” — and I never asked for them; I asked for new mail only. On iOS an app cannot throw away a notification once the system has handed it over, so each of these becomes a visible notification that is simply untrue.
Change an email on my Mac, marking it as read – my phone buzzes.
RFC 8620, Section 7.2 defines PushSubscription.types as the list of data types a client wants StateChange notifications for, with null (or an absent value) meaning “all types”. An empty list therefore means the client wants no StateChange notifications at all – is that right?
Stalwart 1.0.2 however does deliver StateChange notifications to a subscription created with "types": []. For a client that subscribes only for urn:ietf:params:jmap:emailpush notifications, there is currently no way to turn StateChange off.
None of this can be fixed on the client side: a UNNotificationServiceExtension is required to decrypt the payload, but it cannot discard a notification it has been handed, and the push endpoint in this setup holds no keys and so cannot tell the two kinds apart either (see Additional Context).
I am dependent on Stalwart sending the right notifications. Well, actually, I found a workaround for now: use Urgency as a marker, and let the device decide what the relay drops.
Both ends are deliberately blind — the iOS extension can decrypt but cannot discard a notification, and the relay holds no keys, so it cannot tell the two kinds apart. The one difference visible without touching the ciphertext is the Urgency header, and EmailPushConfig carries its own urgency.
So the client orders urgency: “high” for emailPush — purely as a marker, not a priority request. Measured at the relay: Urgency: high for a delivered message, Urgency: normal for a StateChange, with Topic and TTL identical. Delivery is unaffected (anything above low goes out at APNs priority 10).
The catch is that a PushVerification arrives without the marker. A relay with a hardcoded “drop anything but high” rule would swallow it, and push could then never be set up again — silently. So the rule is not in the relay: the app registers twice per launch, first with no marker (it does not yet know whether it is about to create a subscription and wait for verification), then with the urgency that may still pass once push really stands. A dropped push gets a 201 — accepted, since an error would make the server retry or discard the subscription — and every drop is logged, so a wrongly set marker shows up instead of losing mail. With no instruction stored, everything passes.
Size would separate just as cleanly (230 vs 614 bytes) and is deliberately not used: a threshold set slightly too high drops real mail, and nobody notices that.
Expected Behavior
Nothing is pushed. "types": [] selects no StateChange types, and a keyword change is not an emailPush event, since no message was delivered.
I hope I’m right here.
Actual Behavior
One StateChange notification arrives per Email/set, at the subscription’s url, encrypted as usual and decryptable with the subscription’s keys.
Measured on a real device: marking a single message as read produced one such notification, and the client’s “last notification received” diagnostic showed StateChange (Email, Mailbox).
Reproduction Steps
-
Create a push subscription that asks for
emailPushonly and explicitly opts out of everyStateChangetype:{ "using": [ "urn:ietf:params:jmap:core", "urn:ietf:params:jmap:emailpush" ], "methodCalls": [ ["PushSubscription/set", { "create": { "sub": { "deviceClientId": "<client-generated id>", "url": "https://relay.example/p/<opaque token>", "keys": { "p256dh": "<base64url>", "auth": "<base64url>" }, "types": [], "emailPush": { "<accountId>": { "properties": [ "id", "from", "subject", "preview", "threadId", "receivedAt" ], "filter": { "inMailbox": "<inboxId>" }, "urgency": "normal" } } } } }, "0"] ] }The server accepts all of this, including
keys,types: []and theemailPushconfig, and sends thePushVerificationas expected. -
Confirm the subscription with the verification code.
-
From any client, change a keyword on an existing message — no new message is delivered:
["Email/set", { "accountId": "<accountId>", "update": { "<emailId>": { "keywords/$seen": null } } }, "0"] -
Observe what arrives at the subscription’s
url.
Relevant Log Output
Decrypted on the device (RFC 8291), the payload of step 4 is:
{
"@type": "StateChange",
"changed": { "<accountId>": { "Email": "<state>", "Mailbox": "<state>" } }
}
For comparison, the two kinds of notification as they arrive at the push endpoint. These are my own relay’s log lines (German; Topic ohne means no Topic header was sent). The first is the StateChange above, the second a genuinely delivered message, with urgency: "high" ordered in EmailPushConfig:
Push mit Inhalt, Urgency normal, Topic ohne, TTL 86400, 230 Byte
Push mit Inhalt, Urgency high, Topic ohne, TTL 86400, 614 Byte
Stalwart Version
v1.x
Installation Method
Binary (Linux)
Database Backend
RocksDB
Blob Storage
RocksDB
Search Engine
Internal
Directory Backend
Internal
Additional Context
- Stalwart 1.0.2
- Push path: Web Push (RFC 8030, RFC 8188, RFC 8291) with VAPID (RFC 9749)
urn:ietf:params:jmap:emailpush(draft-ietf-jmap-emailpush), advertised by the server both incapabilitiesand in the account’saccountCapabilities- Client: a personal JMAP client (iOS/macOS), not a public product
I have reviewed the documentation and FAQ and confirm that my issue is NOT addressed there.
on
I have searched this support forum (open and closed topics) and confirm this is not a duplicate.
on
I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.
on