ReviewOS

also looking at this

mail-os/mail

Harden encrypted mail storage, recovery, and forwarding

#8
Merged chris wants to merge codex/mail-storage-hardening into main
50 files +1701 -9001
docs/FORWARDING.mdadded+45-0
Changes to docs/FORWARDING.md
@@ -0,0 +1,45 @@
1# Forwarding
2
3Forwarding is declared in each Stacks application's `config/email.ts`:
4
5```ts
6forwards: {
7 'socials@stacksjs.com': ['chris@stacksjs.com'],
8 'hi@stacksjs.com': ['chris@stacksjs.com'],
9}
10```
11
12Buddy merges those declarations into the shared `/opt/mail/forwards.json`
13manifest and atomically compiles `/opt/mail/forwards.sieve`. The runtime script
14uses the standard RFC 5228 Sieve `envelope`, `redirect`, and `keep` commands.
15The JSON file is retained as a generated compatibility manifest for older
16server binaries; it is not the configuration source.
17
18Example generated rule:
19
20```sieve
21require ["envelope"];
22
23if envelope :is "to" "socials@stacksjs.com" {
24 redirect "chris@stacksjs.com";
25 keep;
26}
27```
28
29Rules are loaded for each accepted non-junk message. `keep` leaves the original
30copy in the role mailbox, while `redirect` creates the forwarded copy. Junk is
31not forwarded, which prevents the server from relaying spam.
32
33Reconcile from configuration and validate the live script:
34
35```bash
36buddy mail:provision --env production
37buddy mail:forward:compile
38```
39
40The compiler rejects invalid mailbox names, invalid destination addresses,
41empty target lists, and control characters. It sorts rules and removes
42duplicate targets for deterministic output.
43
44Implementation follow-up is tracked in
45[mail-os/mail#6](https://github.com/mail-os/mail/issues/6).