Kantoor.Forwarding (Kantoor v1.0.0)

Verified mailbox and external-alias forwarding.

Every settings operation refreshes the caller's authorization from Postgres. Internal mailboxes can be selected immediately; external targets receive a single-use, 24-hour confirmation link. Opening a link never activates it: the recipient must explicitly accept. Only token hashes are stored.

enqueue/3 runs inside the ingest transaction. The durable queue is processed by Kantoor.Forwarding.Worker, using row locks across replicas. A local copy is removed only after all queued recipients have accepted the message. Blocked or failed forwards keep it. Disabling forwarding or deleting a target cancels future deliveries. SMTP/API acceptance is at-least-once: a network failure after Karta accepted a send can cause a retry with the same Message-ID.

Summary

Functions

The active destinations displayed in the inbox.

Adds one of at most five targets. External addresses need confirmation.

Consumes a valid confirmation token atomically.

Reads confirmation details without activating forwarding.

Creates an external alias and its destinations atomically, then sends confirmations.

Counts deliveries for an authorized source.

Queues active targets within the caller's ingest transaction.

Finds an external alias without changing ordinary mailbox/alias precedence.

Returns a source's settings, checking current ownership or admin access.

Removes a target and its pending queue entries.

Reissues an unconfirmed destination's link, invalidating its old token.

Processes a bounded queue batch; safe to call on any replica.

Saves enabled/keep-copy; never trusts target or source ids in params.

Resolves a settings-page source without revealing another user's mailbox.

Functions

active_addresses(source)

The active destinations displayed in the inbox.

add_target(scope, source, address)

Adds one of at most five targets. External addresses need confirmation.

confirm(token)

Consumes a valid confirmation token atomically.

confirmation(token)

Reads confirmation details without activating forwarding.

create_alias(scope, domain, attrs)

Creates an external alias and its destinations atomically, then sends confirmations.

delivery_counts(scope, source)

Counts deliveries for an authorized source.

enqueue(source, payload, message \\ nil)

Queues active targets within the caller's ingest transaction.

external_alias(address)

Finds an external alias without changing ordinary mailbox/alias precedence.

get(scope, source)

Returns a source's settings, checking current ownership or admin access.

remove_target(scope, source, id)

Removes a target and its pending queue entries.

resend_confirmation(scope, source, id)

Reissues an unconfirmed destination's link, invalidating its old token.

run_pending()

Processes a bounded queue batch; safe to call on any replica.

save(scope, source, attrs)

Saves enabled/keep-copy; never trusts target or source ids in params.

source(scope, kind, id)

Resolves a settings-page source without revealing another user's mailbox.