Self Host Wizard Documentación

Correo web (snappymail)

Correo web en una caja Self Host Wizard: la pieza snappymail, en webmail.<dominio de apps>, ingreso forward, límite de memoria 192 MB.

De un vistazo

DatoValor
Direcciónhttps://webmail.<dominio de apps>
Ingresoforward: Caddy le pregunta a Authelia antes de que la app vea el pedido (forward auth)
Límite de memoria192 MB (ram_mb: pico medido × 1,3)
Base de datosninguna compartida: guarda sus datos en THX_DATA
Necesitastalwart, authelia
La necesitannada
Contenedoressnappymail
Imagen: snappymaildjmaze/snappymail:v3.1.4-1@sha256:13006205801c5f3e365738265f69289f9e8eb68870e17cd08859396c3c9fc341
Licencia (según el README)AGPL-3.0
Proyecto original (según el README)https://github.com/the-djmaze/snappymail

Cómo activarla

thx enable agrega snappymail y todo lo que necesita al estado de la caja; después thx apply la instala. Las apps se aplican recién cuando site_domain está definido.

sudo thx enable snappymail
sudo thx apply

Notas técnicas (pieces/snappymail/README.md)

Las notas técnicas de cada pieza están en inglés, tal como están en el repositorio.

Webmail at webmail.<apps_domain>. The person signs in once, at Authelia. SnappyMail then opens their own mailbox in Stalwart with no second password and no setup screen. It keeps no accounts, only per-user settings.

auth = "forward": every path is behind Caddy's forward_auth, and Caddy replaces client-sent Remote-* headers with Authelia's answer. SnappyMail never binds to LLDAP, so it gets no THX_LDAP_* and lldap is not on its network.

Upstream: the-djmaze/snappymail v3.1.4, AGPL-3.0. Image djmaze/snappymail:v3.1.4-1@sha256:13006205…c9fc341 (the maintainer's), a multi-arch index with linux/arm64 (docker buildx imagetools inspect, 2026-11-24).

How the mailbox opens

  • Master user. Stalwart lets the LLDAP service user thx-snappymail@<apps_domain> impersonate (the stalwart piece grants it while snappymail is in THX_PIECES). Its password is this piece's ldap_password secret, and core keeps that user (lane report).

    • IMAP and SMTP log in as <person's address>%thx-snappymail@<apps_domain> with the master password.
    • The person's own password is never asked for and never used.
  • **scripts/thx-guard.php** is PHP's auto_prepend_file, so it runs before SnappyMail on every request. A request without exactly one well-formed address in Remote-Email gets 403 and nothing else (pages, JSON API and the ?ThxLogin hook alike).
  • **scripts/thx-sso plugin:**

    • ?ThxLogin (custom_login_link) logs in Remote-Email's mailbox and redirects to the app. A person without a mailbox gets 503, not a redirect loop.
    • Every IMAP, SMTP and Sieve login is rewritten to the master login, and only for the address in Remote-Email. A login for any other address (the Login action, AccountSetup) is refused.
    • Before SnappyMail reads its session cookie, a cookie that belongs to someone other than Remote-Email is dropped. Example: the same browser after another person signed in to Authelia.
    • Upstream bug worked around: SnappyMail 3.1.4's filter.account hook cannot stop such a cookie. Account::NewInstanceFromTokenArray returns the account even when the hook throws, because the index page and AppData call it with throw = false. The test caught alice's session being served to bob's header.
  • The master password reaches PHP through a tmpfs file (/run/thx, root:www-data 0440). php-fpm clears the environment, and the variable is unset after the copy.
  • TLS. IMAP 993 and SMTP 465 are implicit TLS with certificate verification on (files/default.json: verify_peer, no self-signed). mail.<apps_domain> resolves to Stalwart itself: apply connects stalwart to this piece's network with that alias, and Stalwart serves the same mail. certificate there, so TLS verifies without leaving the box.
  • Settings. scripts/thx-init.sh runs before the image's /entrypoint.sh on every start. In application.ini it sets:

    • no admin panel;
    • no additional accounts;
    • cookie_default_secure = On (Caddy terminates TLS);
    • the login link ./?ThxLogin;
    • the logout link https://auth.<apps_domain>/logout, so signing out ends the Authelia session.

    It checks that the key lines landed.

Measured (dev PC, amd64, test.sh, 2026-11-25)

snappymail 121 / 94 MB peak (two runs, docker stats every second; sign-in, send, list, restart)

ram_mb = 192, not 121 × 1.3 = 157. One PHP request may use up to MEMORY_LIMIT = 128 MB (a large attachment), and the test never does.

test.sh

The stalwart piece's throwaway stack (../stalwart/test/stack.sh, which keeps thx-snappymail in LLDAP), then SnappyMail as its own compose project on its own piece network. The test drives SnappyMail's JSON API the way the browser does, with the Remote-* headers Caddy would set sent by hand.

It proves:

  • No Remote-Email, an empty one, a bare name or two addresses → 403 on /, Ping, AppData, ?ThxLogin and the JSON API.
  • alice opens webmail signed in, with no password, and every cookie is Secure. Sign-out goes to Authelia's logout.
  • alice and bob (another company's domain) each send over 465 and see only their own mail.
  • alice's session cookie with Remote-Email bob is not signed in and gets no mailbox.
  • Inside alice's session, Login as bob (with bob's real password) and AccountSetup for bob are refused.
  • A signed-in person without a mailbox gets 503. The admin panel is off.
  • All of the above again after a restart.
  • Without the test CA, ?ThxLogin gets 503: the master password is never sent to a server SnappyMail cannot verify.
  • The master password is not in the log, plain or base64.

It prints PASS snappymail ram_peak_mb=<n>.

Mutations that make it fail (2026-11-25): no guard (/ without a header answered 302), and no identity check in the plugin (alice logged in as bob).

Known gaps

  • Core must keep the LLDAP user thx-snappymail@<apps_domain> with this piece's ldap_password (lane report). Without it, ?ThxLogin answers 503.
  • Contacts are SnappyMail's own (per user, in THX_DATA); no CardDAV link to Radicale yet.
  • org-* groups mean nothing here.

Los datos de esta página salen de estos archivos del repositorio selfhostwizard:

  • pieces/snappymail/piece.toml
  • pieces/snappymail/compose.yaml
  • pieces/snappymail/README.md
  • internal/piece/piece.go

Esta página se genera desde el código al compilar el sitio, así que cambia cuando cambia el código.