LibrePortal
Sponsor
Install

Stalwart

Mail Server

Stalwart is a complete mail server, with calendars and contacts too. Run it privately for your household, or as a real internet mail server for your own domain.

On this page
  1. At a glance
  2. What it's good for
  3. Before you go public
  4. Signing in
  5. Reading your mail
  6. More than one domain
  7. Moving your mail in
  8. Good to know
  9. What the install asks
  10. Addresses and ports
  11. Settings
  12. In its config file
  13. Tools
  14. Works with
  15. Privacy and security
  16. What leaves this server
  17. What LibrePortal turns off
  18. Sources
  19. Under the hood

Good to know before you install

Stalwart downloads its spam-filter rules and its web admin from GitHub, which sees this server's address when it does; the mail itself never goes there.

At a glance#

What it is
Mail Server Communication
Where it opens
Admin Interface On its own port at http://your-server:port, or mail.your-domain once you have a domain
Updates
Automatic A backup is taken first, and it rolls back if the update fails
Backups
Included Part of the daily backup when that's switched on
Copies
One per server
Needs
A domain for public mail

What it's good for#

Stalwart gives you mailboxes at your own address, and everything that goes with them: sending and receiving, folders, spam filtering, calendars and address books that sync to your phone. It's one app, and LibrePortal sets it up for you, so the first time you open it you see a configured mail server rather than a setup wizard.

It comes with a question you answer once, and can change later: who is it for?

  • Private: mail, calendars and contacts for the people on your own network (and your VPN). Mail between your own accounts works normally, but nothing is exchanged with the internet. No domain, no DNS, and nothing to go wrong with deliverability. A good choice for a household calendar and a family address book, or for trying Stalwart out.
  • Public: a real internet mail server that sends to and receives from Gmail, Outlook and everyone else. It needs a domain, and more of your attention.

If you don't choose, LibrePortal picks for you when it installs: Public if Traefik is installed (which in practice means you have a domain pointing here), Private if not. Either way, the answer is written down, and Mail Exposure on the Tools tab switches between them later in both directions.

Before you go public#

Running your own internet mail is very doable, but it's worth knowing what you're taking on:

  • Port 25 has to be open both ways. Other mail servers deliver to you on port 25, and you deliver to them on it. Many VPS providers block outgoing port 25 until you ask them to open it, and most home internet connections block it for good. The install checks and tells you.
  • Reverse DNS (PTR) for your server's address should be your mail hostname, mail.example.com. You set it in your VPS provider's control panel, not in your domain's DNS.
  • DNS records: MX, SPF, DKIM and DMARC at your domain. The install prints the exact records, with your real DKIM keys, and Show DNS Records on the Tools tab prints them again whenever you need them.
  • Reputation takes time. Even with everything right, big providers are wary of a brand-new server and may put your first mail in spam for a few weeks. That's not a fault in the setup, and no installer can skip it.

Let Stalwart manage the records

If your domain's DNS is at Cloudflare, DigitalOcean or deSEC, Stalwart can write and update the records itself through their API, including DKIM keys when it rotates them. Set CFG_STALWART_DNS_PROVIDER and CFG_STALWART_DNS_API_TOKEN in its config file. The token can change your DNS, so scope it to this one domain if your provider lets you.

Signing in#

Stalwart has two web pages on the same address, which you open with the Admin Interface button (mail.example.com with a domain):

  • /admin, the admin console, for the server itself: domains, accounts, the mail queue and reports. Sign in as admin with the password from the Login Details shown when the install finished; press Welcome on the app's page to see it again.
  • /account, for everyday users to change their own password, set up filters and turn on an out-of-office reply.

The install also creates one real mailbox, postmaster@ your domain, because the DMARC and TLS reports other servers send you are addressed there and would bounce without it. Its password is in the same Login Details, as First Mailbox Password. If you change that password later, in a mail app or the admin console, LibrePortal doesn't see the change, and the card keeps showing the old one.

Then add an account for each person in the admin console. The admin login is for running the server, not for reading mail.

The admin login is LibrePortal's

LibrePortal gives Stalwart its admin login every time it starts, as Stalwart's recovery administrator, so it always works even if you've changed things in the console. Change it through LibrePortal, not in Stalwart. To check: document how to change Stalwart's admin password: there is no Tools-tab action for it. Check whether the Config tab shows CFG_STALWART_ADMIN_PASSWORD_1, and whether changing it there and pressing Update Configuration gives Stalwart the new recovery admin (it reaches the container as STALWART_RECOVERY_ADMIN through the app's .env)

Reading your mail#

The easy way is SnappyMail, the webmail app. Stalwart offers it as a companion when you install it, and SnappyMail connects itself to every domain Stalwart handles, so you just sign in with your full email address and mailbox password. Once it's installed, Stalwart's page has an Open webmail button.

Any ordinary mail app works too: Thunderbird, the mail app built into your phone, FairEmail or K-9 Mail on Android. With a domain, many find the settings themselves from your email address. If yours asks, the server is mail.example.com for both incoming and outgoing mail, and:

What Port Security
Incoming (IMAP) 993 SSL/TLS
Outgoing (SMTP) 465 SSL/TLS
Outgoing, if 465 doesn't suit 587 STARTTLS

The username is your full email address. On a private server, use the server's address on your network, 192.168.1.50, instead of mail.example.com. The certificate is then Stalwart's own, and each mail app asks you once whether to trust it.

Calendars and contacts sync over CalDAV and CardDAV, from the same address as the web pages. On Android, DAVx⁵ is the usual app for this; iPhones and Thunderbird can add a CalDAV or CardDAV account directly. Sign in with your email address and password.

More than one domain#

Stalwart can carry mail for several domains on the one server, say your family name and a small business. Each gets its own DKIM keys, a postmaster@ address and a SnappyMail sign-in, all on the one mail hostname.

  • Add a Mail Domain on the Tools tab does it straight away, with no reinstall. Tick Also add it to this server's domains if it isn't one of the domains in Admin → Network yet.
  • Mail Domains shows the list, and whether SnappyMail follows each one.
  • Stop Managing a Mail Domain takes one off LibrePortal's list. It deletes nothing: the mailboxes and keys stay in Stalwart.
  • Re-apply Mail Domains puts Stalwart and SnappyMail back in line with the list. It's safe to run any time.

Then add each new domain's DNS records, from Show DNS Records. Only the first domain needs the A record and the PTR; the others just point their MX at the same mail hostname.

Moving your mail in#

Mail Migration on the Tools tab brings existing mailboxes over from Gmail, Outlook or any provider that offers IMAP. It copies every folder with its flags and dates, lets you check each mailbox arrived, and then helps you switch your domain's DNS over. Running it again only copies what's new, so a last pass after the switch catches anything that arrived in between. Your provider may ask for an app password rather than your normal one.

Good to know#

  • Certificates. With Traefik, the mail ports use Traefik's certificate for your mail hostname. Sync Mail Certificate copies it across, and it also does that every day on its own.
  • Ports are fixed. Mail ports have to be the standard numbers, because other servers and mail apps expect them: 25, 465, 587 and 993. IMAP with STARTTLS (143), POP3 (995) and ManageSieve (4190) are off until you switch them on. If a mail app says the server refused it on 587, run Repair Mail Ports.
  • Paperless. Paperless-ngx can collect attachments from a Stalwart mailbox. You set that up in Paperless, on its Mail page.
  • Updates. Fixes to Stalwart 0.16 arrive automatically. Moving to a new release line, like 0.17, is a deliberate step, because Stalwart is still settling its storage before 1.0.
  • Backups stop Stalwart for a few seconds, so the message store is copied in a consistent state. Mail sent to you in those seconds waits and is retried, which is what mail servers do.
  • Timezone. Installs made before 0.4.7 run Stalwart on UTC whatever the server's timezone, because of a mistake in its setup. Installs from 0.4.7 get the server's timezone. To fix an older install, press Update Configuration on its Config tab once LibrePortal is on 0.4.7: that sets it up again from the corrected template, and your mail stays where it is.

What the install asks#

When you install Stalwart, LibrePortal asks for a little more than usual before it starts:

  • Quick settings

Addresses and ports#

Stalwart has 9 ports. LibrePortal picks a free port number for each when you install, so yours will differ from anyone else's. The Config tab's Network section shows them, and the app's Open button uses the right one. "Anyone" means it's reachable from wherever your server is reachable; you can make it private later.

What it isWho can reach itWith a domain
Admin Interface Anyone mail.your-domain
SMTP (server-to-server mail delivery) TCP Anyone Port only
Mail submission (implicit TLS) TCP Anyone Port only
Mail submission (STARTTLS) TCP Anyone Port only
IMAP (implicit TLS) TCP Anyone Port only
IMAP (STARTTLS) — enable only if a client needs it TCP Off until you turn it on Port only
POP3 (implicit TLS) — off by default, IMAP is preferred TCP Off until you turn it on Port only
ManageSieve (client-managed mail filters) TCP Off until you turn it on Port only
HTTPS/JMAP direct — leave disabled when Traefik fronts the UI TCP Off until you turn it on Port only

Settings#

These are Stalwart's own settings on its Config tab. The settings every app shares, like backups, updates and where its data lives, are explained in App pages and settings.

SettingWhat it doesStarts as
Allow Encrypting Stored Mail Lets each person choose to have their stored mail encrypted with a key only they hold. It never encrypts anyone's mailbox on its own. On

In its config file#

A few more aren't on the Config tab yet. They live in the app's config file, described here so you know they exist. How to change them.

SettingWhat it doesStarts as
Name
CFG_STALWART_DISPLAY_NAME
What this app is called on your dashboards. Leave empty to use its usual name Empty
Show on the LibrePortal Dashboard
CFG_STALWART_SHOW_ON_DASHBOARD
Whether this app gets a shortcut on the front page of the LibrePortal WebUI, separate from any Dashy dashboard
Choices: true, false
true
Detailed logs
CFG_STALWART_VERBOSE_LOGS
Whether Stalwart writes its normal, chattier logs, including who connected, instead of only warnings and errors.
Choices: true, false
false
Debug logging for 24 hours
CFG_STALWART_DEBUG_LOGS
Turn on to see everything Stalwart is doing while you look for a problem; it turns itself off after 24 hours.
Choices: true, false
false
Domain Support
CFG_STALWART_DOMAIN_SUPPORT
What this app can do with more than one domain tenants
Domain Change
CFG_STALWART_DOMAIN_CHANGE
What moving it to another domain after install breaks warn
Extra Mail Domains
CFG_STALWART_DOMAINS_EXTRA
The other domains this server carries mail for, comma-separated Empty

Tools#

Stalwart's Tools tab has 9 buttons for jobs you'd otherwise need a terminal for. Each one runs as a task, so you can watch it on the Tasks page and read what it did. More about Tools.

Mail Domains

The domains this server carries mail for, and whether SnappyMail follows them.

Add a Mail Domain

Carry mail for one more domain now, with its own DKIM keys and a SnappyMail sign-in.

Asks for: Domain, Also add it to this server's domains
Stop Managing a Mail Domain

LibrePortal stops managing a domain. Nothing is deleted: its mailboxes and DKIM keys stay in Stalwart.

Asks for: Domain
Re-apply Mail Domains

Put Stalwart and SnappyMail back in line with the mail domains above. Safe to run any time.

Mail Exposure

Switch between a private mail + calendar server and a real internet mail server.

Asks for: Who is this mail server for?
Show DNS RecordsTested on 0.16.22

Print the records this domain needs, including the live DKIM keys.

Sync Mail Certificate

Use Traefik's certificate for the mail host on the mail ports (465, 587, 993). Also runs daily by itself.

Repair Mail Ports

Give every published mail port (587, and 143 when it is on) a listener behind it. Restarts Stalwart only if one was missing.

Mail MigrationTested on 0.16.22

Bring mailboxes over from Gmail, Outlook or any IMAP provider, check they arrived, then cut DNS over.

Works with#

These are the other apps Stalwart knows how to work with. Once it's installed, its page shows the same list with whether each one is connected. How this works.

  • Bookstack: Sends invitations, password resets and notifications through your mail server, from an account of its own.
  • Forgejo: Sends its own email (password resets, notifications, invitations) through your mail server, from an account of its own.
  • Friendica: Sends registration and notification emails through your mail server, from an account of its own, unless a mail server is set in its own settings. Needs the mail server to have a real certificate.
  • Funkwhale: Sends sign-up confirmations and password resets through your mail server, from an account of its own. Needs the mail server to have a real certificate.
  • Gitea: Sends its own email (password resets, notifications, invitations) through your mail server, from an account of its own.
  • Grafana: Sends its alerts and invitations through your mail server, from an account of its own.
  • Grafana: Shows dashboards for the apps that have one. works with every app
  • Home Assistant: Automations can send you email.
  • Mastodon: Sends sign-up confirmations, password resets and notifications through your mail server, from an account of its own, unless a mail server is set in its own settings.
  • Mattermost: Sends invitations, password resets and missed-message emails through your mail server, from an account of its own.
  • Mobilizon: Sends event and account emails through your mail server, from an account of its own, unless a mail server is set in its own settings. Needs the mail server to have a real certificate.
  • Nextcloud: Sends its own email (password resets, notifications, invitations) through your mail server, from an account of its own.
  • ntfy: Can forward a notification by email through your mail server, from an account of its own. Needs the mail server to have a real certificate.
  • ownCloud: Sends shares and password resets through your mail server, from an account of its own. Needs the mail server to have a real certificate.
  • Paperless-ngx: Sends password resets and shared-document emails through your mail server, from an account of its own. Needs the mail server to have a real certificate.
  • Paperless-ngx: Can collect document attachments from a mailbox.
  • PeerTube: Sends sign-up and password emails and notifications through your mail server, from an account of its own, unless a mail server is set in its own settings. Needs the mail server to have a real certificate.
  • Prometheus: Collects metrics from the apps that can export them. works with every app
  • Rallly: Sends invitations and sign-in links through your mail server, from an account of its own, unless a mail server is set in its own settings. Needs the mail server to have a real certificate.
  • Rocket.Chat: Sends invitations, password resets and offline-message emails through your mail server, from an account of its own. Needs the mail server to have a real certificate.
  • SnappyMail: Webmail for the mailboxes on your mail server.
  • Uptime Kuma: Watches your apps and shows when one goes down. works with every app
  • Vaultwarden: Sends invitations and new-device alerts through your mail server. On by itself once that server can mail the internet, since an invitation then has to be opened from the email.
  • Vikunja: Sends reminders, password resets and task notifications through your mail server, from an account of its own.
  • Zulip: Sends invitations, password resets and missed-message emails through your mail server, from an account of its own. Needs the mail server to have a real certificate.

Privacy and security#

Worth knowing Stalwart keeps your mail on your server and sends no usage reports. It downloads spam rules and its admin pages from GitHub, and does normal mail lookups.

What leaves this server#

  • Spam-filter rules and the web admin are downloaded from GitHub
  • Normal mail traffic: DNS blocklists, SPF and DMARC lookups, Let's Encrypt for certificates

What LibrePortal turns off#

Nothing needed switching off.

Licence: AGPL-3.0 (community); optional paid Enterprise licence. Audited: 21 October 2026. See the privacy of every app and the Promise.

Sources#

Under the hood#

  • It runs this image: stalwartlabs/stalwart:v0.16.27@sha256:c429b311c93db5606598abc1c68225a85a6953183848ae01bee9c6a98885836c.
  • It can sit behind Authelia's sign-in once Authelia is installed.
  • Its own project and documentation: github.com/stalwartlabs/stalwart

Ports, settings, tools and connections on this page are read from LibrePortal v0.10.97's app catalogue each time the guide is built.

Next steps