Receiver-side companion to age-web-gateway. Watches your IMAP inbox, decrypts .age-encrypted attachments with your private age key, and saves the plaintext files — with their original filenames restored — to a local directory.
age-web-gateway lets anyone send you encrypted messages and files from a browser at age.hdev.io. All encryption happens client-side before anything leaves the sender's device; only ciphertext reaches your inbox. age-imap-decryptor is the other half: it sits next to your mailbox and automatically decrypts everything that arrives.
Sender (browser)
│ client-side age encryption
▼
age-web-gateway ──────────────────► Your IMAP inbox
encrypted email │
age-imap-decryptor
│
decrypted/
└── 2026-05-25_18.13.45Z_7/
├── message.age.plain
└── screenshot-age-web.png
- Initial scan — processes all existing messages in the mailbox on startup
- IMAP IDLE — reacts to new mail within seconds, no polling required
- Sidecar-aware rename —
attachment-001.payload.ageis renamed to the original filename declared in the accompanyingattachment-001.meta.agesidecar - Stateless deduplication — uses output directory names (
<timestamp>_<uid>) to skip already-processed messages; no database or state file needed - Read-only mailbox — no flags are set, no messages are moved or deleted
- Minimal footprint — single static binary; Docker image built on
scratch
IMAP IDLE (RFC 2177) allows the server to push a notification to the client the instant a new message arrives, rather than requiring the client to poll every N seconds. The underlying go-imap library handles the protocol details — IDLE sessions are renewed automatically every ~5 minutes and the connection is re-established after any interruption. The result: decryption happens within seconds of delivery with zero polling overhead.
- age identity file — generate one with
age-keygen:age-keygen -o ~/.age/id.txt # Publish the public key so senders can find it: # DNS TXT _age.<yourdomain.com> "age1..." # or HTTPS https://<yourdomain.com>/.well-known/age
- IMAP mailbox — port 993 (TLS), any provider works
- Sender filter (optional) — set
filter.sender: "[email protected]"to process only gateway-originated mail and ignore everything else
Copy config.example.yaml to config.yaml and fill in your values:
imap:
server: "imap.example.com"
port: 993 # default: 993
username: "[email protected]"
password: "supersecret" # or leave empty and set WATCHER_IMAP_PASSWORD
mailbox: "INBOX" # default: INBOX
filter:
attachment_extension: ".age" # default: .age
sender: "[email protected]" # optional; server-side FROM filter
keys:
path: "~/.age" # directory containing age identity files
output:
base_dir: "/var/lib/age-imap-decryptor/decrypted"
runtime:
initial_scan: true # process existing messages on startup
idle: true # keep running and react to new messages via IMAP IDLEThe password can be supplied via the WATCHER_IMAP_PASSWORD environment variable instead of the config file. Protect config.yaml with chmod 600 if you store the password there.
initial_scan |
idle |
Behaviour |
|---|---|---|
true |
true |
Scan existing messages, then enter IDLE (default) |
true |
false |
One-shot scan, then exit |
false |
true |
IDLE only — skip the initial scan |
false |
false |
Invalid — service exits with an error |
docker run -d \
--name age-imap-decryptor \
--restart unless-stopped \
-v ~/.age:/keys:ro \
-v /var/lib/age-imap-decryptor/decrypted:/output \
-v /path/to/config.yaml:/config.yaml:ro \
ghcr.io/dhcgn/age-imap-decryptor --config /config.yamlSupplying the password via environment variable:
docker run -d \
-e WATCHER_IMAP_PASSWORD=mysecret \
-v ~/.age:/keys:ro \
-v /var/lib/age-imap-decryptor/decrypted:/output \
-v /path/to/config.yaml:/config.yaml:ro \
ghcr.io/dhcgn/age-imap-decryptor --config /config.yamlDownload a pre-built binary from the Releases page, or install with Go:
go install github.com/dhcgn/age-imap-decryptor/cmd/age-imap-decryptor@latest# Default: scan existing messages, then enter IDLE
./age-imap-decryptor --config config.yaml
# One-shot scan only (no IDLE)
./age-imap-decryptor --config config.yaml --idle=false
# IDLE only (skip initial scan)
./age-imap-decryptor --config config.yaml --scan=falseThe service handles SIGINT / SIGTERM for clean shutdown.
git clone https://github.com/dhcgn/age-imap-decryptor
cd age-imap-decryptor
go build ./cmd/age-imap-decryptorRequires Go 1.25 or later.
Each processed message gets its own directory named <UTC-timestamp>_<IMAP-UID>:
decrypted/
└── 2026-05-25_18.13.45Z_7/
├── message.age.plain ← decrypted message body
├── attachment-001.meta.age.plain ← sidecar JSON (kept for reference)
└── screenshot-age-web.png ← payload renamed from original filename
The sidecar file contains the original filename, MIME type, size, and SHA-256 of the payload — everything needed to verify the file after decryption.
If a message has already been processed (directory with matching _<uid> suffix exists), it is skipped on restart — no duplicate output, no state file required.
- age-web-gateway — sender-side browser tool; live instance at age.hdev.io
- age — the underlying encryption format and Go library