Skip to content

Template

Self-host Stalwart mail on a server you own.

A mail and collaboration server: SMTP, IMAP, POP3, JMAP, ManageSieve, CalDAV and CardDAV in one binary. It is the template with the most setup after install, because mail involves DNS, certificates and ports the proxy does not handle.

At a glance

Image
stalwartlabs/stalwart:v0.16.21
Web port
8080, behind kamal-proxy
Health check
/healthz/live
Mail ports
25, 465, 587, 143, 993, 110, 995, 4190
Volumes
etc, data
Singleton
yes

What the install does

  • Publishes the eight mail ports on the machine, and opens them on the cloud firewall at each deploy on an API-managed server
  • Sets STALWART_PUBLIC_URL from the environment's domain at each deploy
  • Registers the etc and data volumes for backup

Every deploy is a short mail outage: two containers cannot hold the same port, so the old one stops first. Sending servers retry, so inbound mail is delayed rather than lost.

Before you start

  • 01

    A server of its own if you can. Two environments on one machine cannot both hold port 25.

  • 02

    Control of the mail domain's DNS. KamalCloud never writes DNS records.

  • 03

    A plan for outbound port 25, which Hetzner, DigitalOcean and AWS block on new accounts.

FAQ

Questions about Stalwart.

Read the Stalwart guide
Can I send mail from Hetzner, DigitalOcean or AWS?

Receiving works. Sending needs outbound port 25, which all three block on new accounts, so ask the provider to lift it or send through a relay.

Who handles certificates for IMAP and SMTP?

kamal-proxy holds the certificate for the web admin and JMAP. The mail ports need their own: set up ACME with a DNS-01 challenge in Stalwart, or upload a certificate you obtained elsewhere, remembering that nothing renews it.

Does KamalCloud create the MX, SPF, DKIM and DMARC records?

No. Stalwart shows the records it wants in its admin UI, and you publish them at your DNS provider. Set reverse DNS for the server's IP at the cloud provider as well.

How are backups taken?

Configuration lives in the etc volume and mailboxes in data. The data volume stops the container while it is archived, because RocksDB writes continuously. Back up both together: a mail store restored without its configuration is not much use.

Run your own mail server.

Connect a server of its own, install Stalwart, and deploy when the hostname points at it.

Sign-ups are paused while the app is in maintenance.