RFC: Gmail / Google Workspace accounts in Bulwark via a standalone JMAP bridge — feedback wanted #1007
Replies: 2 comments
|
https://github.com/bulwarkmail/legacy-proxy is probably the best starting point |
|
A follow-up three weeks on, since the suggestion to start from legacy-proxy worked out. Where it stands The Gmail backend lives in legacy-proxy as one PR, bulwarkmail/legacy-proxy#14. It talks to the Gmail API, not IMAP. I have been running it daily for a personal Gmail and a Google Workspace account, next to Stalwart, in the same Bulwark. What a Gmail account can do in Bulwark through it today:
Most of the recent work was about speed with many accounts: Gmail's batch endpoint for labels and messages, an encrypted cache keyed by account state, and answering folder and tag counts from label counters instead of searches. What it needs from Bulwark Almost nothing, as hoped. A few small webmail PRs make it nicer, and each stands on its own:
Limits, honestly
If the maintainers would rather see the Gmail backend as its own project, or split differently, I am happy to reshape it. Review on legacy-proxy#14, even partial, is very welcome. |
Uh oh!
There was an error while loading. Please reload this page.
Hi all — before investing weeks into this, I'd like a sanity check from maintainers and anyone who has thought about it.
The problem
Bulwark is JMAP-native, which is exactly why I use it. But like many people I still have Gmail / Google Workspace mailboxes I can't migrate, and today the only way to see them in Bulwark is one-way ingestion into Stalwart (getmail/imapsync). That's a mirror, not the mailbox: read state, moves and deletions never flow back to Google.
The idea
A standalone JMAP server ("bridge") that exposes a Gmail account over RFC 8620/8621 by talking to the Gmail API (not IMAP). Users add it as an additional account through the existing custom JMAP endpoint support — no changes to Bulwark core.
Why Gmail API rather than an IMAP proxy
The old JMAP-over-IMAP approach (Fastmail's
jmap-perl) predates the RFCs and has to fake everything IMAP lacks. Gmail's API is a surprisingly good fit for JMAP instead: stable global message ids, labels ↔mailboxIds(multi-membership, exactly like JMAP), native threads, andhistoryId↔state/Email/changes. Prior art:josephg/gmail-jmapproved the concept but stopped at read-only.What I checked in the Bulwark codebase
Mailbox/get|set,Email/get|query|set,Thread/get,Identity/get,EmailSubmission/set,Email/import, blob download/upload./changesandeventSourceUrldegrade gracefully (full fetch / 3s state polling).core+mail+submissiongives a clean mail-only account.dev-jmapmock route is a great scaffold for the dispatcher.Rough plan
Email/changesviahistoryId, SSE.Known rough edges: Google's restricted OAuth scopes (unverified app = 7-day refresh tokens for personal @gmail.com; fine for Workspace "internal" apps), the 250 units/s quota (needs a local metadata cache), no
$answeredin Gmail, and synthesising a role=allmailbox for archived mail.Questions
bulwarkmailorg, or something else?All reactions