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
Just deployed
/var/lib/hm3/attachments
mariadb
Just deployed
/var/lib/mysql
redis
Just deployed
/data
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 thecyphtservice) - Private URL:
http://cypht.railway.internal:8080 - Credentials: the variable
AUTH_PASSWORDon thecyphtservice is the admin password, given as plain text; the login name isadmin - Auth: Cypht has no REST API. Sign in like a browser:
POST /with the form fieldsusername,passwordand thehm_page_keyprinted in the sign-in form, and anOriginheader 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
#!/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):
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
Template Content
