Self-hosted · Docker · AGPL-3.0

Mail, on
your own domain.

A mail server for your own domains: SMTP for incoming mail, submission for sending from a mail app, IMAPS and POP3S for reading, a browser inbox and an admin console — all in one container. All of its state — configuration, database, DKIM key and certificates — is one config/ directory you can copy.

Status: beta SMTP · IMAPS · POP3S IPv4 + IPv6 7 UI languages SQLite default AGPL-3.0
iMail sign-in page: a blue panel next to an account and password form

What it does

Protocols, mailbox, administration and certificates, all in the same container.

Mail protocols on standard ports

SMTP on 25 with STARTTLS, submission on 587, SMTPS on 465, IMAPS on 993, POP3 on 110 with STLS required before login, POP3S on 995. The web interface uses 80 and 443.

A browser mailbox

Folders, search, conversation view, reply, reply-all, forward, attachment download and light/dark themes. Seven interface languages — the six official UN languages plus Traditional Chinese — chosen from the browser.

Domains, users and quotas

A primary domain plus additional domains, per-mailbox quotas, and an admin console for users, domains, DNS records and certificates.

Certificates

ACME with HTTP-01, manual DNS-01 or a Cloudflare token, or an uploaded certificate. Each domain can have its own; the ACME flows renew automatically.

Deliverability

DKIM signing, SPF checks, DMARC and PTR guidance, and a configurable spam filter. Outbound delivery verifies the remote server's certificate.

One data directory

SQLite by default, MySQL and PostgreSQL for larger installs. Configuration, database, DKIM key and certificates live under config/, so a backup is a directory copy.

Deploy on a VPS

Docker with Compose, a public IPv4 and/or IPv6 address, and a domain whose DNS you control. Port 80 must be reachable for HTTP-01.

Clone and create the data directory

The config/ directory is the whole server state: configuration, SQLite, DKIM key and TLS material.

git clone https://github.com/noelbennettz/imail.git
cd imail
mkdir -p config

Start the published image

This pulls ghcr.io/noelbennettz/imail:latest and publishes the eight mail and web ports. The published addresses, ports and the ./config path are parameters you can change; DOCS.md explains each one, and docker-compose.example.yml in the repository carries every port and volume with a comment.

docker compose -f docker-compose.ghcr.yml up -d
docker compose -f docker-compose.ghcr.yml logs -f imail

Finish the setup wizard

Open http://your-server-ip/ and enter the setup token the container printed at startup: run docker compose logs imail and copy the 24-character token from the line beginning *** Setup token:. The wizard then asks for database, administrator, domains, DNS records and TLS. The token lives in memory only, is needed for every wizard request, and disappears once setup finishes; it stops a stranger from completing setup first, but it does not encrypt the administrator password, so still finish it on a trusted network.

Check port 25 before debugging anything else. Many VPS providers block outbound TCP 25; receiving works, but delivery to other mail servers does not until they lift it. On rootless Docker, publish high host ports instead (8080:80, 18443:443, …) because ports below 1024 cannot be bound.

DNS records and TLS

The setup wizard writes the exact values for every domain; this is their shape.

  • A and AAAA for the mail host. Add the families the server actually has, and MX, SPF, DKIM and DMARC for every domain that receives mail.
  • PTR is set at the VPS, not in your zone. Point reverse DNS at smtp.example.com so receivers can confirm the sending host.
  • TLS covers every hostname clients use. Usually the apex plus smtp., imap., pop. and the web domain.
  • Certificate options. HTTP-01, DNS-01 (manual or a Cloudflare token), or an upload. HTTP-01 and Cloudflare renew automatically.
@                  A/AAAA  203.0.113.10 / 2001:db8::10
mail               A/AAAA  same address
smtp               A/AAAA  same address
@                  MX      10 smtp.example.com.
@                  TXT     "v=spf1 a mx ~all"
default._domainkey TXT     "<from the setup wizard>"
_dmarc             TXT     "v=DMARC1; p=quarantine; rua=mailto:postmaster@example.com"

Propagation takes longer than the wizard. Check with dig +short MX example.com, the DKIM TXT record, _dmarc, and dig -x <server-ip> before blaming the server.

Limits worth knowing

What decides whether iMail fits, before you move an MX record.

  • Port 25 decides whether mail flows. Remote servers connect to inbound 25 only (an MX record has no port field), and outbound 25 is needed to send. Many providers block both; an extra listener on another port only helps the clients you configure yourself.
  • Account names are unique across domains. alice@one.example and alice@two.example cannot coexist; create alice and alice-sales instead.
  • TLS needs the hostname clients use. SNI is checked strictly, so every name a client connects to must be in the certificate. Behind a reverse proxy, preserve SNI and the public hostname.
  • Not every certificate renews itself. HTTP-01 and Cloudflare DNS-01 do; manual DNS-01 records and uploaded certificates you replace by hand.

One server, one database. SQLite suits a single small server; MySQL or PostgreSQL are for deployments that need an external database. IPv4-only and IPv6-only hosts both work, and delivery to an address family the host does not have fails as an ordinary temporary error.

Security defaults

What the server does with passwords, TLS and the first run. iMail is in beta: versions may change incompatibly, so back up config/ before upgrading.

Passwords and sessions

Passwords are stored as salted PBKDF2 hashes and must be at least eight characters. Changing one signs out every existing session.

TLS everywhere

TLS 1.2 and 1.3 only, IMAP is never served without TLS, and outbound delivery fails rather than falling back to plaintext when the remote certificate cannot be verified.

First run and secrets

config/config.json is written with mode 0600. The setup wizard exists only before the first successful initialisation, and its API requires the one-time setup token printed in the container log: finish it on a trusted network, and back up config/ without ever committing it.

Abuse limits and delivery

Five failed SMTP, IMAP or POP3 sign-ins from one address within fifteen minutes block that address for fifteen minutes; an account is only blocked when failures keep coming from several addresses, and the administrator can switch the limit off. Outbound mail — including copies to local mailboxes — is written to a durable queue and retried for up to 72 hours; the admin console shows pending and failed counts.

Reporting a vulnerability

Use the Security tab and Report a vulnerability on GitHub. If that form is unavailable, open an issue titled “Security contact request” with no technical details. SECURITY.md lists the supported versions and what is in scope; there is no response-time guarantee.

Technical details

What runs, what it listens on, and what it stores.

Image
ghcr.io/noelbennettz/imail
Tags
latest, main, sha-<commit>
Platforms
linux/amd64, linux/arm64
Ports
25, 80, 110, 443, 465, 587, 993, 995
State
config/ volume: config, SQLite, DKIM key, certificates
Database
SQLite default; MySQL and PostgreSQL supported
Languages
7 — English, Arabic, Spanish, French, Russian, Simplified Chinese (the six official UN languages) and Traditional Chinese
License
AGPL-3.0

Questions

The things worth knowing before pointing MX records at a new host.

Is this a mail server or just a webmail client?

Both. iMail handles SMTP, submission, SMTPS, IMAPS, POP3/STLS and POP3S, and also serves a browser mailbox and an admin console. Any standard mail client can connect; the web interface is not required for day-to-day mail.

My VPS blocks port 25. Can I still use it?

Only partly. Other mail servers always connect to port 25 — an MX record has no port field — so if inbound 25 is blocked, mail from the internet cannot reach iMail; put a relay or a host with 25 open in front. Your own users can still submit on 587, and outbound delivery needs outbound 25 or a relay.

How does login work with multiple domains?

With one domain, alice and alice@example.com both work. With two or more, the full address is required because the bare name would be ambiguous. Accounts are globally unique: alice@one.example and alice@two.example cannot coexist; name them alice and alice-sales.

Do I have to use its ACME certificates?

No. HTTP-01, manual DNS-01, Cloudflare DNS-01 and uploaded PEM certificates are all supported, globally or per domain. Automatic renewal applies to the two ACME flows; watch uploaded certificates yourself.

Can it run behind a TLS reverse proxy?

Yes. Set httpsEnabled to 2 for HTTP-only mode and let the proxy terminate TLS. Session cookies only get Secure when HTTPS is enabled, so the proxy must be trusted.

What do I back up?

The whole config/ directory: config.json, the SQLite database (or your DSN), the DKIM private key and the certificate directory. Copy it to a new host and the server comes back as it was.

Does it work on an IPv6-only or IPv4-only host?

Yes. IPv4-only, IPv6-only and dual-stack hosts all work; if the configured address family is missing at startup, the other one is used and the reason is logged. A destination that exists only on the missing family cannot be reached, so delivery to it is reported as a temporary failure.

Why AGPL?

Self-hosting, forking and paid support are fine. If you run a modified iMail as a network service, its users must be able to get the source of the version you run; that is section 13.