HUB
Sign inSign up

ipman82ua/mailwall

By ipman82ua

•Updated 7 days ago

Self-hosted SMTP, IMAP and POP3 mail server with a web admin panel, storing mail in PostgreSQL.

Image
Networking
0

237

ipman82ua/mailwall repository overview

⁠MailWall

Self-hosted SMTP, IMAP and POP3 mail server with a web admin panel. Mail is stored in PostgreSQL.

MailWall receives, stores and sends e-mail for your own domains. It's a single Go binary with the admin panel built in. All data is in PostgreSQL (domains, mailboxes, messages, settings and login history), so a database backup is a full backup.

⁠Features

  • Receiving mail: SMTP on port 25 for your domains, with message size and recipient limits.
  • Mail clients:
    • SMTP submission on port 587 with STARTTLS and login.
    • IMAP on ports 143 (STARTTLS) and 993 (TLS), with IDLE, MOVE and folders (INBOX, Sent, Drafts, Trash, Junk).
    • POP3 on port 110.
    • Works with Apple Mail, Thunderbird, Outlook and mobile mail apps.
  • Sending mail:
    • a delivery queue with MX lookup;
    • retries for about 3 days, then a bounce message to the sender;
    • an optional IPv4-only mode;
    • relay networks: trusted IP addresses or networks that may send without logging in, e.g. your web servers.
  • Domains, mailboxes and aliases: per-mailbox quotas; aliases are extra addresses that deliver to the same mailbox.
  • TLS: your own certificate (e.g. Let's Encrypt), per-domain certificates chosen by SNI, or a generated self-signed certificate.
  • Web admin panel (dark theme):
    • Dashboard: service status, statistics, and currently logged-in sessions with IP locations.
    • Domains: a DNS helper that lists the exact MX, A, SPF, DMARC and PTR records and checks them, with hints for Cloudflare and Hetzner.
    • Mailboxes: quota usage, folders, messages and aliases.
    • Queue: outgoing mail with status, attempts and errors; retry or delete.
    • Sessions: login history for IMAP, POP3 and SMTP with filters and paging, kept for a set number of days (30 by default).
    • Setup: mail settings, relay networks, GeoIP database and properties.
    • Admins: administrator accounts.
  • IP locations: country, region and city from a local GeoIP database, downloaded and updated automatically. No IP addresses are sent to outside services.
  • REST API with JWT authentication.
  • Automatic schema migrations at startup; upgrading means pulling the new image and restarting.
  • Logging levels trace, debug, info, warn and error; passwords are removed from protocol logs.

⁠Image

BaseAlpine Linux
Sizeabout 55 MB
Platformslinux/amd64, linux/arm64
Usermailwall (uid 1000); allowed to listen on ports below 1024
Volume/app/data: GeoIP database
Health checkthe admin panel login page

⁠Quick start

⁠docker compose
services:
  postgres:
    image: postgres:17-alpine
    restart: unless-stopped
    environment:
      POSTGRES_USER: mailwall
      POSTGRES_PASSWORD: change-me
      POSTGRES_DB: mailwall
    volumes:
      - postgres:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U mailwall -d mailwall"]
      interval: 5s
      retries: 10

  mailwall:
    image: ipman82ua/mailwall:latest
    restart: unless-stopped
    depends_on:
      postgres:
        condition: service_healthy
    environment:
      MAILWALL_DB_DSN: "host=postgres user=mailwall password=change-me dbname=mailwall sslmode=disable"
    ports:
      - "25:25"
      - "587:587"
      - "110:110"
      - "143:143"
      - "993:993"
      - "127.0.0.1:8080:8080"   # admin panel, local only
    volumes:
      - data:/app/data

volumes:
  postgres:
  data:
docker compose up -d
docker compose logs mailwall | grep password    # first administrator password, printed once
⁠docker run
docker run -d --name mailwall --restart unless-stopped \
  -e MAILWALL_DB_DSN="host=db.example.com user=mailwall password=secret dbname=mailwall sslmode=disable" \
  -p 25:25 -p 587:587 -p 110:110 -p 143:143 -p 993:993 -p 127.0.0.1:8080:8080 \
  -v mailwall-data:/app/data \
  ipman82ua/mailwall:latest
⁠First steps
  1. Open the admin panel at http://127.0.0.1:8080/cabinet/. On the first start the login page shows the generated admin password with a Login button. Save the password: it's shown only until the first login (and is also in the log). From another computer, use an SSH tunnel: ssh -L 8080:127.0.0.1:8080 user@your-server.
  2. On Setup, set the server host name (e.g. mail.example.com).
  3. On Domains, add your domain and create the DNS records shown on the domain page.
  4. On Mailboxes, create a mailbox and set it up in your mail client. Use the full e-mail address as the user name.
  5. Click your login name in the top-right corner to change the administrator password.

⁠Ports

PortService
25SMTP: mail from other servers, and relay for trusted networks
587SMTP submission: sending from mail clients (STARTTLS + login)
110POP3
143IMAP (STARTTLS)
993IMAPS (TLS)
8080Admin panel and REST API (publish on 127.0.0.1 or put it behind a reverse proxy with HTTPS)

⁠Configuration

Startup options are environment variables. Each one also has a command-line flag, which you can pass after the image name.

VariableDefaultDescription
MAILWALL_DB_DSNhost=localhost port=5432 user=postgres password=postgres dbname=mailwall sslmode=disablePostgreSQL connection string
MAILWALL_WEB_HOST0.0.0.0admin panel bind address
MAILWALL_WEB_PORT8080admin panel port
MAILWALL_SMTP_PORT25SMTP port, 0 disables
MAILWALL_SUBMISSION_PORT587submission port, 0 disables
MAILWALL_POP3_PORT110POP3 port, 0 disables
MAILWALL_IMAP_PORT143IMAP port, 0 disables
MAILWALL_IMAPS_PORT993IMAPS port, 0 disables
MAILWALL_TLS_CERTTLS certificate (PEM); a self-signed certificate is generated if empty
MAILWALL_TLS_KEYTLS private key (PEM)
MAILWALL_GEOIP_DB/app/data/geoip.mmdbGeoIP database file
MAILWALL_LOG_LEVELinfotrace, debug, info, warn or error
TZUTCtime zone for log timestamps

Other settings are changed in the admin panel and take effect without a restart. They include the host name, the maximum message size and number of recipients, requiring TLS for logins, IPv4-only sending, login history retention and GeoIP auto-update.

⁠TLS certificates

Without a certificate, MailWall generates a self-signed one. Mail clients will warn about it, and some refuse to connect. To use Let's Encrypt, mount the whole /etc/letsencrypt folder: the files in live/ are links into archive/.

    environment:
      MAILWALL_TLS_CERT: /etc/letsencrypt/live/mail.example.com/fullchain.pem
      MAILWALL_TLS_KEY: /etc/letsencrypt/live/mail.example.com/privkey.pem
    volumes:
      - /etc/letsencrypt:/etc/letsencrypt:ro

The key files must be readable by uid 1000. You can also upload certificates per domain in the admin panel; they're stored in the database.

⁠Sending mail to the internet

Big providers such as Gmail and Outlook accept mail only from correctly configured servers:

  • Port 25: outgoing port 25 must be open; many hosting providers block it until you ask.
  • A record: the mail host name (e.g. mail.example.com) points to the server's public IP.
  • MX record: your domain's MX points to the mail host.
  • SPF: a TXT record such as v=spf1 mx -all that includes the server's IP.
  • DMARC: a TXT record at _dmarc.example.com, e.g. v=DMARC1; p=none; rua=mailto:[email protected].
  • Reverse DNS (PTR): the server's IP resolves back to the mail host name. You set this at your hosting provider.
  • IPv6: if the server has IPv6 without its own PTR and SPF entry, keep IPv4-only sending on (the default) on the Setup page.

The domain page in the admin panel shows the exact records for your server and checks them.

⁠Data and backups

  • PostgreSQL holds everything: mail, accounts, settings, the queue and login history. Back up the database volume, or use pg_dump.
  • /app/data holds only the GeoIP database, which is downloaded again if it's missing.

⁠Upgrading

docker compose pull
docker compose up -d

Database migrations run automatically at startup.

⁠Notes

  • Client IP addresses: with published ports, connections that pass through Docker's userland proxy (for example IPv6 clients) can appear to come from the Docker gateway (172.x.x.x). That affects relay networks, the login history and IP locations. If you see this, run the container with network_mode: host.
  • Admin panel: keep it on 127.0.0.1, or put it behind a reverse proxy with HTTPS. Don't expose port 8080 to the internet unprotected.
  • Relay networks may send mail as anyone. Add only addresses you control.

⁠GeoIP data

IP geolocation by DB-IP⁠, licensed under CC BY 4.0⁠. The free DB-IP City Lite database is downloaded by the container and updated monthly. Automatic updates can be turned off on the Setup page.

Tag summary
Recent tags
Content type
Image
Digest
sha256:0c5d8c076…
Size
14.3 MB
Last updated
7 days ago
docker pull ipman82ua/mailwall:latest