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
//! Outbound mail queue primitives: DKIM signing, DSN generation, MTA-STS
//! lookup, retry/backoff, and a delivery worker over a pluggable store.
//!
//! The "pure" pieces ([`dkim_sign`], [`dsn`], [`mta_sts`], [`retry`])
//! depend only on hashes / DNS / arithmetic. Queue state lives behind the
//! [`QueueStore`] trait and wake-ups behind [`Notifier`]; the crate ships
//! no database backend. Implement the two traits over whatever you store
//! mail in, check the store with [`store::contract::check_queue_store`],
//! and hand both to [`DeliveryWorker`]:
//!
//! ```no_run
//! # async fn run() -> Result<(), Box<dyn std::error::Error>> {
//! use std::sync::Arc;
//! use mailrs_outbound_queue::{DeliveryWorker, InMemoryNotifier, InMemoryQueueStore, WorkerConfig};
//!
//! let store = Arc::new(InMemoryQueueStore::new());
//! let notifier = Arc::new(InMemoryNotifier::new());
//! let resolver = mailrs_smtp_client::TokioResolver::builder_tokio()?.build()?;
//! let worker = DeliveryWorker::new(
//! WorkerConfig::default(),
//! store,
//! notifier,
//! resolver,
//! "mx.example.com".into(),
//! );
//! let (_stop, stopped) = tokio::sync::watch::channel(false);
//! worker.run(stopped).await;
//! # Ok(())
//! # }
//! ```
//!
//! [`InMemoryQueueStore`] and [`InMemoryNotifier`] are complete reference
//! implementations, fit for tests and single-process deployments.
use Arc;
/// Per-domain DKIM key map built from `MAILRS_DKIM_KEYS`.
/// DKIM signing helpers (RFC 6376): config + sign-and-prepend.
/// Which domains a DKIM config can really sign for.
/// 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`] / [`Notifier`] traits, reference impls and the contract check.
/// Async delivery worker that drains the queue + dispatches via SMTP.
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 = ;