---
title: "Deploy Cypht | (Just Updated) Self-Hosted Webmail Client, Roundcube Alternative For Many IMAP Accounts, Login Generated"
description: "Cypht self-hosted webmail client, IMAP inbox, MariaDB and Redis included"
category: "Other"
url: https://railway.com/deploy/cypht-or-just-updated-self-hosted-webmai
---

# Deploy Cypht | (Just Updated) Self-Hosted Webmail Client, Roundcube Alternative For Many IMAP Accounts, Login Generated

Cypht self-hosted webmail client, IMAP inbox, MariaDB and Redis included

**[Deploy Cypht | (Just Updated) Self-Hosted Webmail Client, Roundcube Alternative For Many IMAP Accounts, Login Generated on Railway](https://railway.com/template/cypht-or-just-updated-self-hosted-webmai)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/cypht-or-just-updated-self-hosted-webmai/manifest.json

- **Creator:** SuperSlowSloth
- **Category:** Other

## Template content

### cypht

- **Image:** ghcr.io/bon5co/cypht-railway:2.14.0@sha256:4502efbdc3521e48dbb562091a799828947a6482062a0aa07a1aa1cf68b01d35
- **Health check:** /
- **Public domain:** Yes

### mariadb

- **Image:** mariadb:11.8@sha256:6422478cb8e159f080fb1d8ccf65101e26fe51385787fde7d16c3b165a331f15
- **Start command:** `/bin/sh -c 'set -e; M=$(cat /sys/fs/cgroup/memory.max 2>/dev/null || echo max); if [ "$M" != max ]; then B=$((M / 2 / 1048576)); [ "$B" -lt 128 ] && B=128; else B=512; fi; export MARIADB_DATABASE=cypht MARIADB_USER=cypht; echo "[railway] uid=$(id -u) innodbBufferPoolMB=$B owner=$(stat -c %u:%g /var/lib/mysql)"; exec docker-entrypoint.sh mariadbd --datadir=/var/lib/mysql/data --innodb-buffer-pool-size=${B}M --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci'`

### redis

- **Image:** redis:8.2.1-alpine@sha256:987c376c727652f99625c7d205a1cba3cb2c53b92b0b62aade2bd48ee1593232
- **Start command:** `/bin/sh -c 'chown -R redis:redis /data && exec docker-entrypoint.sh redis-server --requirepass "$REDIS_PASSWORD" --appendonly yes --dir /data --maxmemory 256mb --maxmemory-policy volatile-lru'`

## Documentation

# Deploy and Host Cypht on Railway

**Built for an LLM agent to deploy and use.** The deploy form has no fields to fill: the admin password and the database and Redis passwords are generated, the server cannot start without a strong login, and the database tables are created at boot. Cypht is a self-hosted webmail client that reads many IMAP accounts (and SMTP and POP-style sources) in one combined inbox, an open-source alternative to Roundcube and SnappyMail for people who keep several mailboxes.

## About Hosting Cypht

This template runs three services: **cypht**, the upstream Cypht image pinned by digest through a thin wrapper, **mariadb**, a MariaDB 11.8 database with a volume at `/var/lib/mysql` that holds users, settings and the mail accounts you add, and **redis**, a Redis 8 instance with a volume at `/data` that holds sessions. The `cypht` service has a volume at `/var/lib/hm3/attachments` for uploaded attachments. One public domain serves the web app. The server listens on Railway's injected `PORT`, and the healthcheck is `GET /`.

**What the wrapper fixes.** Upstream's nginx listens on a fixed port 80 and ignores Railway's injected `PORT`, and every setting is a variable the deployer would have to type. The wrapper bakes the fixed settings into the image so the deploy form is empty, points nginx at `PORT` (IPv4 and IPv6) and refuses to start without a login password of at least 12 characters. It also sets `DISABLE_IP_CHECK=true`: Cypht ends a session when the client address changes between requests, and the Railway edge address changes per request, so without it a correct login is accepted and the session is destroyed on the next page, which shows the sign-in form again with "Invalid username or password". This was measured on a Railway deploy of the first wrapper build, where the generated login signed in 0 of 1 attempts, and after the fix 1 of 1. Not reproduced on a Railway control of the incumbent listing.

**Using it.** Open the domain and sign in as `admin` with `AUTH_PASSWORD`. Add your IMAP and SMTP accounts under the accounts page; they are stored in MariaDB, so redeploys keep them. New Cypht logins are created only by a signed-in admin.

### Agent contract

- Public URL: `https://RAILWAY_PUBLIC_DOMAIN` (the generated domain of the `cypht` service)
- Private URL: `http://cypht.railway.internal:8080`
- Credentials: the variable `AUTH_PASSWORD` on the `cypht` service is the admin password, given as plain text; the login name is `admin`
- Auth: Cypht has no REST API. Sign in like a browser: `POST /` with the form fields `username`, `password` and the `hm_page_key` printed in the sign-in form, and an `Origin` header equal to the public URL (a POST without it is treated as cross-site and ends the session). Keep the cookie jar; later calls send it back.
- Health: `GET /` returns 200 without credentials

```bash
#!/bin/sh
# needs: RAILWAY_PUBLIC_DOMAIN, AUTH_PASSWORD (variable of the cypht service; the login name is admin); also curl, grep, sed, cut, mktemp.
R="https://$RAILWAY_PUBLIC_DOMAIN"
J=$(mktemp -d)
n=0; until [ "$(curl -s -o /dev/null -w '%{http_code}' "$R/")" = 200 ]; do n=$((n+1)); [ "$n" -le 60 ] || break; sleep 5; done
curl -s -o /dev/null -w "health: %{http_code}\n" "$R/"
# Cypht has no REST API: the agent signs in like a browser. A POST must carry an Origin header (a missing one is treated as cross-site and ends the session) and the page key printed in the form.
key() { curl -s -c "$1" "$R/" | grep -o 'name="hm_page_key" value="[a-f0-9]*' | head -1 | cut -d'"' -f4; }
login() { curl -s -b "$1" -c "$1" -o /dev/null -H "Origin: $R" --data-urlencode "username=$2" --data-urlencode "password=$3" --data-urlencode "hm_page_key=$4" "$R/"; curl -s -b "$1" -c "$1" "$R/" -o "$1.html"; }
# write-auth: none - Cypht has no write API; its only write path is a signed-in browser session, shown below to be refused for a wrong password and for a stranger
# signup: none - Cypht has no public registration; the login is created at boot from AUTH_PASSWORD and new accounts are made only by a signed-in admin
# a stranger posting a new account (no session), then trying to sign in as it, gets the sign-in form back
K=$(key "$J/s"); curl -s -b "$J/s" -c "$J/s" -o /dev/null -H "Origin: $R" --data-urlencode "create_username=stranger" --data-urlencode "create_password=Stranger-pass-123456" --data-urlencode "create_password_again=Stranger-pass-123456" --data-urlencode "hm_page_key=$K" "$R/?page=accounts"
K=$(key "$J/t"); login "$J/t" stranger "Stranger-pass-123456" "$K"; echo "stranger signed in: $(grep -c 'class="logout_form"' "$J/t.html")"
# a wrong password does not sign in
K=$(key "$J/w"); login "$J/w" admin "not-the-admin-login" "$K"; echo "wrong password signed in: $(grep -c 'class="logout_form"' "$J/w.html")"
# the generated login signs in: the page then carries the logout form and the sign-in form is gone
K=$(key "$J/a"); login "$J/a" admin "$AUTH_PASSWORD" "$K"; echo "generated login signed in: $(grep -c 'class="logout_form"' "$J/a.html")"
# an ajax call without a session is not served ("not callable"); with the session it answers JSON and reports the login state
K=$(grep -o 'name="hm_page_key" value="[a-f0-9]*' "$J/a.html" | head -1 | cut -d'"' -f4)
echo "ajax without session: $(curl -s -H "Origin: $R" -H "X-Requested-With: XMLHttpRequest" --data-urlencode "hm_ajax_hook=ajax_hm_folders" --data-urlencode "hm_page_key=x" "$R/" | grep -o '"status":"[^"]*"')"
echo "ajax with session: $(curl -s -b "$J/a" -H "Origin: $R" -H "X-Requested-With: XMLHttpRequest" --data-urlencode "hm_ajax_hook=ajax_hm_folders" --data-urlencode "hm_page_key=$K" "$R/" | grep -o '"router_login_state":[a-z]*')"
```

Expected output against a fresh deploy (measured on the Railway demo and on a control deploy of the published code; the output is recorded in `template.md`):

```text
health: 200
stranger signed in: 0
wrong password signed in: 0
generated login signed in: 1
ajax without session: "status":"not callable"
ajax with session: "router_login_state":true
```

The refusals are the contract: a stranger's account creation and login, and a wrong password, leave the sign-in form in place (`signed in: 0`), and an ajax call without a session is answered `not callable`. There is no sign-up route, which the `# signup: none` line in the snippet states.

## Why Deploy Cypht on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Cypht on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

- **Agent-ready** - no deployer fields, a contract block, and one script that proves the server is healthy, a stranger and a wrong password do not sign in, and the generated login does.
- **Locked from the first request** - the server will not start without a strong admin password, and the tables exist before the first visit.
- **Works on first deploy** - the listener follows Railway's injected `PORT`, and sessions survive the changing edge address.
- **Data survives redeploys** - accounts and settings live in MariaDB on a volume, sessions in Redis on a volume, attachments on a volume.
- **Pinned** - the upstream image is pinned by digest and the wrapper by tag and digest.

## Common Use Cases

- **One inbox for many mailboxes** - read Gmail, Outlook and your own IMAP servers in a single combined view.
- **A shared webmail front end** - give a small team a browser mail client on your own domain.
- **A self-hosted Roundcube replacement** - keep mail access off third-party webmail.

## Dependencies for Cypht Hosting

- The cypht service, a MariaDB service and a Redis service, each with its volume, created by the template.

### Deployment Dependencies

- [Cypht repository](https://github.com/cypht-org/cypht)
- [Cypht website](https://cypht.org)
- [Wrapper image source](https://github.com/bon5co/cypht-railway)


## Similar templates

- [Rocky Linux](https://railway.com/deploy/rocky-linux) — Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀
- [Foundry Virtual Tabletop](https://railway.com/deploy/X5tR6G) — Self-hosted virtual tabletop for role-playing games (license required)
- [Double Commander in your browser](https://railway.com/deploy/double-commander-in-your-browser) — The Double Commander file manager in the cloud, from any device

Open this page in a browser: https://railway.com/deploy/cypht-or-just-updated-self-hosted-webmai
