Skip to content

s3lfcod3r/selfarchiver

Repository files navigation

SelfArchiver

Self-hosted email archiver that keeps your mailbox small and your mail safe — with the controls other archivers are missing.

English · Deutsch

License: MIT GHCR image


Most archivers can only mirror a whole account. SelfArchiver is built around four things they don't do:

  • 📂 Selective folders — archive only the folders you choose (e.g. Invoices, Insurance), never the spam-filled inbox.
  • 🎛 Rule-based filters — match by sender, subject, attachment presence and age, with read/flagged safeguards so important or unread mail is never touched.
  • ⏱ Per-rule schedules — every rule runs on its own cron schedule, completely independent of the others.
  • 🧹 Archive-then-delete retention — optionally delete mail from the source mailbox after it has been safely archived, so a free mailbox quota is enough.

Everything lives in one container: SQLite (with full-text search) and .eml files on a single volume. No Postgres, Redis, search engine or Tika sidecars to run.

⚠️ Status: v1.0.0. The archive-then-delete action permanently removes mail from your mailbox once archived — test with Archive only first and keep backups of anything irreplaceable.


Features

Sources Connect any IMAP mailbox. Credentials are encrypted at rest (AES-256-GCM).
Folder picker Lists the mailbox's folders and lets you tick exactly which to archive.
Filter From/Subject/To contains-any, require attachment, only-read, exclude-flagged.
Age Only act on mail older than N days.
Schedule Per-rule cron with presets, custom expressions and a live "next run" preview.
Retention Archive only or Archive, then delete from mailbox. Deletion only happens after a confirmed archive.
Archive Browse + full-text search (subject, sender, recipients, body). Download any message as .eml.
Activity Run history with scanned / archived / deleted counts and errors.
Interface Dark or light UI, English & German (switchable in the sidebar), collapsible navigation; click an archived email to read it inline.
Auth Optional single-password login for the whole UI.

How it works

  1. You add an IMAP mailbox (source).
  2. You create one or more rules: pick folders, set a filter, choose an age threshold, a schedule and whether to delete after archiving.
  3. On schedule (or Run now), SelfArchiver lists messages older than the threshold in each selected folder, archives the ones matching the filter (full .eml incl. attachments) into the database + disk, and — if enabled — deletes those messages from the mailbox.

Archiving is idempotent: a stable per-message key prevents duplicates, so re-running a rule is always safe.

Quick start

Docker Compose

git clone https://github.com/s3lfcod3r/selfarchiver.git
cd selfarchiver
cp .env.example .env
# set APP_SECRET (openssl rand -hex 32) and optionally AUTH_PASSWORD
docker compose up -d

Open http://<host>:3000.

Unraid

The template lives at unraid/selfarchiver.xml. Add this repo as a template source, or paste the XML into a new container template. Set APP_SECRET (and optionally AUTH_PASSWORD) and map /data to e.g. /mnt/user/appdata/selfarchiver.

The image is published to GHCR: ghcr.io/s3lfcod3r/selfarchiver:latest.

Configuration

Variable Default Description
PORT 3000 HTTP port.
APP_SECRET (auto) Secret for encrypting mailbox passwords + signing sessions. Set and keep stable.
AUTH_PASSWORD (empty) Optional UI password. Empty = open instance.
COOKIE_SECURE false Set to true when serving over HTTPS (behind a TLS proxy) so the session cookie is only sent over secure connections.
TZ / CRON_TZ UTC Timezone for cron schedules.
DATA_DIR /data SQLite DB + .eml archive location.
LOG_LEVEL info traceerror.

Development

npm install
npm run dev       # backend on :3000 (tsx watch)
npm run dev:web   # frontend on :5173 (Vite, proxies /api)
npm run typecheck # type-check both workspaces
npm run build     # build web + prepare server

Stack: Node + Fastify + better-sqlite3 (FTS5) + imapflow + node-cron on the backend; React + Vite + Tailwind on the frontend. See docs/ARCHITECTURE.md.

Security notes

  • Mailbox passwords are encrypted with a key derived from APP_SECRET. Losing/changing the secret makes them unrecoverable.
  • Run behind HTTPS (reverse proxy) if exposed beyond a trusted LAN, and set AUTH_PASSWORD.
  • The Archive, then delete action is irreversible on the mailbox side. The archive copy remains, but treat it like any retention policy.

License

MIT — see LICENSE. SelfArchiver is an independent implementation; see NOTICE.md.

About

Self-hosted email archiver - rule-based IMAP archiving into a single SQLite container, with optional delete-after-archive.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages