jmap

package
v1.42.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 28 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package jmap is the JMAP protocol backend (RFC 8620, 8621; ADR 0037): a backend.Receiver and backend.Sender over an account's JMAP session.

Index

Constants

View Source
const ReasonNoSubmission = "jmap.no_submission"

ReasonNoSubmission is the add-account check's refusal of a JMAP server (or API token) whose session does not advertise urn:ietf:params:jmap:submission.

Variables

View Source
var ErrNoSubmission = errors.New(ReasonNoSubmission)

ErrNoSubmission is Check or Send on a session without JMAP email submission. Its message is ReasonNoSubmission. Check returns it with a full CheckResult: the account can still receive.

Functions

This section is empty.

Types

type Config

type Config struct {
	// SessionURL is the session resource, or /.well-known/jmap to discover it.
	SessionURL  string
	Credentials backend.CredentialsFunc
	// SentFolder, when non-nil, overrides which mailbox Sender files the sent
	// copy into: *SentFolder is the target Mailbox id, or "" when the account
	// has no Sent folder (the staged copy is destroyed once submitted). When
	// nil, Sender uses the server's RoleSent mailbox.
	SentFolder *backend.FolderRef
}

Config is how to reach an account.

type Receiver

type Receiver struct {
	// contains filtered or unexported fields
}

Receiver is a JMAP account's receiving backend. Its folders are mailboxes (FolderRef is the Mailbox id), a message's ServerID and every MessageRef of it are its Email id, and its cursor is the account's Mailbox and Email state.

func New

func New(cfg Config) *Receiver

New is a Receiver for the account cfg names. It connects on first use.

func (*Receiver) Apply

func (r *Receiver) Apply(ctx context.Context, op backend.Op) (backend.Result, error)

Apply implements backend.Receiver: each op is one Email/set. The Email id stays the same wherever the message goes, so Done carries it.

func (*Receiver) Check

func (r *Receiver) Check(ctx context.Context) (backend.CheckResult, error)

Check implements backend.Receiver.

func (*Receiver) Close

func (r *Receiver) Close() error

Close implements backend.Receiver.

func (*Receiver) Describe

func (r *Receiver) Describe(ctx context.Context) (backend.Description, error)

Describe implements backend.Receiver. Its first call signs in, fetching the session, so refused credentials are ErrAuthFailed here.

func (*Receiver) Fetch

Fetch implements backend.Receiver. Sync gives the whole message, which local storage parses, so a part is named by its IMAP part path ("1.2") and cut from the whole message, still transfer-encoded as IMAP gives it. shortcut: a part downloads the whole message; use the part's own blobId from bodyStructure if large mail makes that slow.

func (*Receiver) Find

func (r *Receiver) Find(ctx context.Context, folder backend.FolderRef, messageID string, size int64) ([]backend.MessageRef, error)

Find implements backend.Receiver.

func (*Receiver) Headers

func (r *Receiver) Headers(ctx context.Context, folder backend.FolderRef, refs []backend.MessageRef, fields []string) (map[backend.MessageRef][]byte, error)

Headers implements backend.Receiver. shortcut: one download per message, as Fetch; ask Email/get for the header:* properties of all refs at once if refreshes get slow.

func (*Receiver) Sync

func (r *Receiver) Sync(ctx context.Context, req backend.SyncRequest, commit func(backend.Page) error) (bool, error)

Sync implements backend.Receiver. It reports changes since the cursor and the mail a window wider than the cursor's adds, or everything in the window at first and after the server cannot calculate changes (then each folder is reset first, and stored mail the window left out is found again by id). It always syncs the whole account: Only is not used, nor are Pages and PageSize, so more is false. shortcut: no 加载更早 (Older) on JMAP yet, so it is ErrUnsupported; add an Email/query past each folder's window when core asks for it.

func (*Receiver) Watch

func (r *Receiver) Watch(ctx context.Context, wake func(folders []backend.FolderRef)) error

Watch implements backend.Receiver over the session's EventSource. It wakes for every state the server sends, the one on connect included, which covers what changed while it was not connected. When the server closes the stream, or sends nothing, not even a ping, for watchStall, it connects again.

type Sender added in v1.35.0

type Sender struct {
	// contains filtered or unexported fields
}

Sender is a JMAP account's sending backend (RFC 8621 section 7): it uploads the RFC 5322 message as a blob, then imports the Email and creates an EmailSubmission with an explicit envelope and onSuccessUpdateEmail in one JMAP request.

func NewSender added in v1.35.0

func NewSender(cfg Config) *Sender

NewSender is a Sender for the account cfg names.

func (*Sender) SavesSent added in v1.35.0

func (s *Sender) SavesSent() bool

SavesSent implements backend.Sender: Email/import + onSuccessUpdateEmail places the sent copy in the Sent mailbox on the server, unless the follow-up Email/set failed (or the configured Sent mailbox was missing), in which case SavesSent reports false so core's outbox archives or retains recovery state.

func (*Sender) Send added in v1.35.0

func (s *Sender) Send(ctx context.Context, from string, rcpts []string, raw []byte) error

Send implements backend.Sender. Any failure before the EmailSubmission/set HTTP request is written whole (session, Identity/get, blob upload) is a plain error (or ErrAuthFailed / *RejectedError) and safe to retry. Once the submission HTTP request has been written, a lost response (timeout, dropped connection, unreadable body, or HTTP 5xx) returns backend.ErrUncertain.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL