Expand description
Outbound mail queue primitives: DKIM signing, DSN generation, MTA-STS lookup, retry/backoff, plus a pluggable store trait and a Postgres reference implementation.
mailrs-outbound-queue extracts the queue + delivery layer from
mailrs so it can be reused — or driven by a custom store — in any Rust
MTA. The “pure” pieces (dkim_sign, dsn, mta_sts, retry)
depend only on hashes / DNS / pure arithmetic; the QueueStore +
Notifier traits in store decouple delivery state from any
particular backend.
§Feature flags
| Feature | Default | Includes |
|---|---|---|
pg | on | PgQueueStore + RedisNotifier + the bundled DeliveryWorker that consumes them. Pulls in sqlx and redis. |
Disable the pg feature if you want only the traits + pure primitives:
mailrs-outbound-queue = { version = "1", default-features = false }§Two paths
The crate exposes two parallel APIs against the same underlying queue semantics:
- Trait API (
QueueStore,Notifier) — the portable surface. Use this if you want a non-PG backend, or if you want your own delivery loop. An always-availableInMemoryQueueStoreis included for tests + pilots. - PG free functions in the
queuemodule — convenience for the common case where you already have asqlx::PgPooland just wantqueue::enqueue(pool, ...). These back the bundledDeliveryWorkerand are what mailrs itself uses.
Both APIs are stable for v1.x and back-compatible. The trait API plus a generic worker is the target for v2.
Re-exports§
pub use dkim_sign::DkimSignConfig;pub use queue::QueueStatus;pub use queue::QueuedMessage;pub use retry::retry_delay_secs;pub use retry::retry_delay_secs_jittered;pub use retry::should_bounce;pub use store::InMemoryNotifier;pub use store::InMemoryQueueStore;pub use store::NoopNotifier;pub use store::Notifier;pub use store::QueueStore;pub use store::StoreError;pub use pg_store::PgQueueStore;pub use pg_store::RedisNotifier;pub use worker::DeliveryWorker;pub use worker::WorkerConfig;pub use worker::group_by_domain;
Modules§
- dkim_
sign - DKIM signing helpers (RFC 6376): config + sign-and-prepend.
- dsn
- Delivery Status Notification (RFC 3464) formatting.
- mta_sts
- MTA-STS (RFC 8461) policy lookup + caching.
- pg_
store - Postgres-backed
QueueStoreimplementation (feature-gated). Postgres / Redis-backed implementations ofQueueStoreandNotifier. - queue
- Queue row type, status enum, and retry-attempt bookkeeping.
- retry
- Exponential-backoff retry math + “is it permanent?” classifier. Exponential-backoff retry helpers for SMTP outbound delivery.
- store
- Pluggable
QueueStoretrait + an in-memory reference impl. Storage abstractions for the outbound queue. - worker
- Async delivery worker that drains the queue + dispatches via SMTP (feature-gated).
Enums§
- Delivery
Event - Outbound delivery event for external observers (admin UI, audit log, metrics pipeline, TLSRPT reporter).
- TlsAttempt
Outcome - Outcome of one STARTTLS attempt, carried by
DeliveryEvent::TlsAttempt. The four variants discriminate between TLS success, server-side refusal (still safely usable in plain), and handshake failure (with the structuredmailrs_smtp_client::TlsOutcomeunderneath).
Type Aliases§
- Delivery
Event Sender - Callback channel for
DeliveryEventnotifications. Wrapped inArcso the worker can clone it across spawned delivery tasks.