Self-hosted SMTP, IMAP and POP3 mail server with a web admin panel, storing mail in PostgreSQL.
237
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.
trace, debug, info, warn and error; passwords are removed from protocol logs.| Base | Alpine Linux |
| Size | about 55 MB |
| Platforms | linux/amd64, linux/arm64 |
| User | mailwall (uid 1000); allowed to listen on ports below 1024 |
| Volume | /app/data: GeoIP database |
| Health check | the admin panel login page |
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 -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
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.mail.example.com).| Port | Service |
|---|---|
| 25 | SMTP: mail from other servers, and relay for trusted networks |
| 587 | SMTP submission: sending from mail clients (STARTTLS + login) |
| 110 | POP3 |
| 143 | IMAP (STARTTLS) |
| 993 | IMAPS (TLS) |
| 8080 | Admin panel and REST API (publish on 127.0.0.1 or put it behind a reverse proxy with HTTPS) |
Startup options are environment variables. Each one also has a command-line flag, which you can pass after the image name.
| Variable | Default | Description |
|---|---|---|
MAILWALL_DB_DSN | host=localhost port=5432 user=postgres password=postgres dbname=mailwall sslmode=disable | PostgreSQL connection string |
MAILWALL_WEB_HOST | 0.0.0.0 | admin panel bind address |
MAILWALL_WEB_PORT | 8080 | admin panel port |
MAILWALL_SMTP_PORT | 25 | SMTP port, 0 disables |
MAILWALL_SUBMISSION_PORT | 587 | submission port, 0 disables |
MAILWALL_POP3_PORT | 110 | POP3 port, 0 disables |
MAILWALL_IMAP_PORT | 143 | IMAP port, 0 disables |
MAILWALL_IMAPS_PORT | 993 | IMAPS port, 0 disables |
MAILWALL_TLS_CERT | TLS certificate (PEM); a self-signed certificate is generated if empty | |
MAILWALL_TLS_KEY | TLS private key (PEM) | |
MAILWALL_GEOIP_DB | /app/data/geoip.mmdb | GeoIP database file |
MAILWALL_LOG_LEVEL | info | trace, debug, info, warn or error |
TZ | UTC | time 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.
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.
Big providers such as Gmail and Outlook accept mail only from correctly configured servers:
mail.example.com) points to the server's public IP.v=spf1 mx -all that includes the server's IP._dmarc.example.com, e.g. v=DMARC1; p=none; rua=mailto:[email protected].The domain page in the admin panel shows the exact records for your server and checks them.
pg_dump./app/data holds only the GeoIP database, which is downloaded again if it's missing.docker compose pull
docker compose up -d
Database migrations run automatically at startup.
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.127.0.0.1, or put it behind a reverse proxy with HTTPS. Don't expose port 8080
to the internet unprotected.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.
docker pull ipman82ua/mailwall:latest