Raven is a small mail server written in Zig. It currently provides SMTP, IMAP, filesystem-backed storage, tenant-aware routing, and optional TLS.
- SMTP listener with inbound delivery
- IMAP listener with mailbox access
- Filesystem-backed mail storage
- Tenant/domain routing and alias lookup
- Account authentication from local storage
- Optional TLS via OpenSSL
- Graceful shutdown on signal
- Zig 0.16
- OpenSSL 3
- macOS build support currently expects Homebrew OpenSSL at
/opt/homebrew/opt/openssl@3
zig build
zig build testzig build run -- \
--listen-address 127.0.0.1 \
--listen-port 5882 \
--imap-port 1143 \
--hostname localhost \
--data-dir dataOn first run, Raven creates its filesystem layout under --data-dir.
Generate a short-lived local certificate:
openssl req -x509 -newkey rsa:2048 -nodes \
-keyout key.pem -out cert.pem -days 1 \
-subj "/CN=localhost"Start Raven with TLS enabled:
zig build run -- \
--listen-address 127.0.0.1 \
--listen-port 5882 \
--imap-port 1143 \
--hostname localhost \
--data-dir data \
--tls-cert cert.pem \
--tls-key key.pemConnect with openssl s_client:
openssl s_client -connect 127.0.0.1:5882 -quiet -CAfile cert.pem
openssl s_client -connect 127.0.0.1:1143 -quiet -CAfile cert.pemRaven accepts configuration from:
- CLI flags
- Environment variables
key = valueconfig files
Common options:
--config--listen-address--listen-port--imap-port--hostname--data-dir--tls-cert--tls-key
Environment variables use the RAVEN_ prefix:
RAVEN_CONFIGRAVEN_LISTEN_ADDRESSRAVEN_LISTEN_PORTRAVEN_IMAP_PORTRAVEN_HOSTNAMERAVEN_DATA_DIRRAVEN_TLS_CERTRAVEN_TLS_KEY
Example config file:
listen_address = 127.0.0.1
listen_port = 5882
imap_port = 1143
hostname = localhost
data_dir = data
tls_cert_file = cert.pem
tls_key_file = key.pem
zig build testruns the unit test suite.- For a manual smoke test, connect to the SMTP and IMAP ports and verify the greeting banners.
src/main.zigwires configuration, startup, TLS, and shutdown.src/server.zighandles SMTP sessions and inbound delivery.src/imap.zighandles mailbox access and IMAP commands.src/storage.zigmanages the filesystem layout and message files.src/config.zigloads CLI, environment, and config-file settings.src/tls.zigwraps OpenSSL for server-side TLS.src/tenant_index.zig,src/alias_index.zig, andsrc/account_index.zigprovide routing and identity lookup.
- Keep changes small and focused.
- Run
zig buildandzig build testbefore opening a PR. - If you touch startup, TLS, or storage behavior, add or update tests.
- Prefer minimal changes that preserve the current architecture.
MIT