nextcloud / nextcloud/mail

Read-only JMAP Support

Open
#12,610 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

2. developing enhancement
Dominant language
JavaScript
Stars
1k
Forks
348
Avg merge
12h 28m
Merged PRs (30d)
91

Description

Summary

Implement read-only JMAP support: connect to JMAP servers, sync mailbox structure, and fetch messages.

Problem

Users with JMAP-enabled accounts cannot access their mail via Nextcloud Mail.
We need to add JMAP as a supported protocol with feature parity to IMAP for reading mail.

Solution

  • Create JMAP client factory using SebastianKrupinski/jmap-client-php
  • Implement mailbox structure sync and conversion to domain models
  • Implement message fetching and conversion to domain models
  • Handle JMAP Session endpoint discovery and state-based sync
  • Ensure output uses same domain models as IMAP

Implementation

Create lib/JMAP/ namespace for JMAP-specific logic:

  • JmapClientFactory - creates and configures JMAP client
  • JmapMailboxMapper - converts JMAP Mailbox objects to domain models
  • JmapMailboxSync - syncs folder structure into database
  • JmapMessageMapper - converts JMAP Message objects to MessageDTO
  • JmapSync - orchestrates message sync using JMAP state tokens

Credential handling reuses existing encryption patterns.

Session discovery fetches .well-known/jmap for JMAP capabilities.

Sync strategy:

  • Full sync on first run
  • Incremental sync using JMAP state tokens on subsequent runs
  • Detects new/changed/deleted messages

Message extraction:

  • Headers (To, From, Subject, Date, Message-ID, References, In-Reply-To)
  • Flags and keywords
  • Attachment metadata
  • Message IDs for threading

Affected Components

  • New: lib/JMAP/ directory with mappers and sync logic
  • ProtocolClientFactory: register JmapClientFactory (from https://github.com/nextcloud/mail/issues/12609)
  • SyncService: use dispatcher to call appropriate sync
  • composer.json: add SebastianKrupinski/jmap-client-php dependency

Acceptance Criteria

  • JMAP accounts can be created (via https://github.com/nextcloud/mail/issues/12609 infrastructure)
  • Connection test validates JMAP server availability
  • Mailbox structure syncs correctly
  • Messages fetch with all required properties
  • Output matches IMAP mapper format (same domain models)
  • Existing IMAP sync unaffected

Out of Scope

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing IMAP sync and mapper flow, then inspect ProtocolClientFactory, SyncService, composer.json, and the proposed lib/JMAP/ namespace. Confirm how the JMAP client dependency, session discovery, state-based synchronization, and domain model conversions fit the existing flow. Done means read-only JMAP accounts sync mailboxes and messages with the same models while IMAP behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, backend, database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.