mailrs-sieve
Clean delivery-action wrapper over Stalwart's sieve-rs (RFC 5228
Sieve email filtering + the common extensions: fileinto,
vacation, reject, redirect, …).
sieve-rs is a complete Sieve implementation but exposes a
low-level event-loop API — every MTA has to write the same
translation layer to turn sieve::Event variants into actual
delivery decisions. mailrs-sieve IS that layer:
- Flat
SieveAction { Keep, FileInto, Discard, Redirect, Reject, Vacation }enum the caller pattern-matches in its delivery loop created_messagestracking sovacation/notifyreply bodies are correctly paired with theirSendMessageevents- Envelope
From/Toinjection for:envelopetests + vacation auto-reply addressing
Pure compile + evaluate. No I/O, no async. Plug into any script-storage layer (PG, file, in-memory) and any delivery backend (Maildir, IMAP, JMAP).
Quick start
use ;
let script = "fileinto \"INBOX/spam\";";
let compiled = compile_sieve.unwrap;
let message = b"From: a@b.c\r\nSubject: t\r\n\r\nbody";
let actions = evaluate_sieve_with_envelope;
match &actions
API
| Function | Purpose |
|---|---|
compile_sieve(script) |
Parse + compile a Sieve script to an Arc<CompiledSieve> |
evaluate_sieve(compiled, msg) |
Evaluate against a message (no envelope) |
evaluate_sieve_with_envelope(compiled, msg, from, to) |
Evaluate with envelope info (needed for vacation, :envelope) |
SieveAction |
Enum of delivery decisions: Keep, FileInto(String), Discard, Redirect(String), Reject(String), Vacation(String, Vec<u8>) |
What this crate does NOT do
- No script storage — caller persists scripts however they like (PG, file, ManageSieve).
- No delivery — caller's MTA executes the
SieveAction. - No vacation deduplication — caller tracks "have we replied to this address in the last N days?" using their own state store.
- No
notifyextension specifics —notifyreply bodies are returned viaSieveAction::Vacation(same shape, different semantics; caller decides whether to actually send).
License
Apache-2.0 OR MIT.