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