1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
//! 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`] + [`KevyNotifier`] + the bundled [`DeliveryWorker`] that consumes them. Pulls in `sqlx` and `kevy-embedded`. |
//!
//! Disable the `pg` feature if you want only the traits + pure primitives:
//!
//! ```toml
//! 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-available [`InMemoryQueueStore`] is included
//! for tests + pilots.
//! - **PG free functions** in the [`queue`] module — convenience for the
//! common case where you already have a `sqlx::PgPool` and just want
//! `queue::enqueue(pool, ...)`. These back the bundled
//! [`DeliveryWorker`] and 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.
//!
//! [mailrs]: https://github.com/goliajp/mailrs
//! [`mailrs-smtp-client`]: https://crates.io/crates/mailrs-smtp-client
use Arc;
/// DKIM signing helpers (RFC 6376): config + sign-and-prepend.
/// Delivery Status Notification (RFC 3464) formatting.
/// MTA-STS (RFC 8461) policy lookup + caching.
/// Queue row type, status enum, and retry-attempt bookkeeping.
/// Exponential-backoff retry math + "is it permanent?" classifier.
/// Pluggable [`QueueStore`] trait + an in-memory reference impl.
/// Postgres-backed [`QueueStore`] implementation (feature-gated).
/// Async delivery worker that drains the queue + dispatches via SMTP (feature-gated).
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
/// Outbound delivery event for external observers (admin UI, audit log,
/// metrics pipeline, TLSRPT reporter).
/// 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 structured
/// [`mailrs_smtp_client::TlsOutcome`] underneath).
/// Callback channel for [`DeliveryEvent`] notifications. Wrapped in `Arc` so
/// the worker can clone it across spawned delivery tasks.
pub type DeliveryEventSender = ;