Futuristic SMTP INBOUND-only server for home usage. Zero SPAM, IMAP and Ical Calendar
  • Ada 68.2%
  • Python 24%
  • C 7.5%
  • Dockerfile 0.2%
Find a file
2026-11-18 20:54:59 +01:00
.vscode Some improvement 2026-05-10 14:45:42 +02:00
smoketest Graylist: a client certificate is known by its SHA-256 fingerprint 2026-11-15 11:13:59 +01:00
src DAV: a login that succeeds is logged at info, one that fails at warn, as IMAP's: event=login result=success|failure, the reason no_credentials or wrong_credentials, the peer, the X-Forwarded-For a proxy adds, method and path; a successful request was silent unless DEBUG 2026-11-18 20:54:59 +01:00
.dockerignore ZangTumb 3.0.0 in Ada, third part: CalDAV and CardDAV; the Go code goes 2026-11-14 14:34:20 +01:00
.drone.yml Drone: the image goes to Docker Hub and the service runs it from there 2026-11-14 15:34:11 +01:00
.gitignore PROXY protocol on SMTP and IMAP; reverse lookups bounded 2026-11-14 15:27:25 +01:00
docker-compose.example Documentation: installing version 3, with and without the PROXY protocol [skip ci] 2026-11-14 16:41:59 +01:00
Dockerfile Image: tzdata, so TZ sets the time of the log and of Received headers 2026-11-14 15:09:30 +01:00
LICENSE Update 'LICENSE' 2021-02-02 19:09:02 +00:00
Makefile PROXY protocol on SMTP and IMAP; reverse lookups bounded 2026-11-14 15:27:25 +01:00
README.md Graylist: a client certificate is known by its SHA-256 fingerprint 2026-11-15 11:13:59 +01:00
SINGLE_DOMAIN_GUIDE.md Graylist: a client certificate is known by its SHA-256 fingerprint 2026-11-15 11:13:59 +01:00
smoketest.py ZangTumb 3.0.0 in Ada, third part: CalDAV and CardDAV; the Go code goes 2026-11-14 14:34:20 +01:00
traefik-tcp.example.yml Documentation: installing version 3, with and without the PROXY protocol [skip ci] 2026-11-14 16:41:59 +01:00
zangtumb.gpr ZangTumb 3.0.0 in Ada, third part: CalDAV and CardDAV; the Go code goes 2026-11-14 14:34:20 +01:00

ZangTumb

Futuristic SMTP/IMAP/CalDAV/CardDAV catch-all server for home usage. Inspired by Marinetti's RFC (also known as the Manifesto of Futurism).

It serves a single domain in catch-all mode: one mailbox for every recipient at that domain.

Every message sent to your domain will be accepted and stored in a single Maildir.
Spammers waste resources; you receive every message.

Version 3 is written in Ada, its parsers in SPARK (proved free of run-time errors), on tested C libraries: OpenSSL, libetpan for reading MIME, libmicrohttpd and libxml2 for DAV. Whatever answers the network is Ada. It reads and writes the same files as the Go versions 1 and 2, so it replaces them on the same data, and they can read its data back.

WHAT IT DOES

  • SMTP, inbound only. Mail for any address at DOMAINNAME lands in one Maildir. STARTTLS is mandatory, and the sending server must show a valid client certificate (see Who may deliver). It is not a relay and sends nothing.
  • Graylisting, optional: the first try with a client certificate not seen before is told to come back later.
  • IMAP4rev1 for the one user, with IDLE, UIDPLUS, MOVE, ESEARCH, LIST-EXTENDED, STARTTLS and the rest a mail client expects.
  • CalDAV and CardDAV, optional: one calendar and one address book.
  • PROXY protocol, optional: behind Traefik or HAProxy, the client's real address is the one logged and counted.

WHAT YOU NEED

  1. A domain, and its MX record pointing to the host that receives mail on port 25 (directly, or through a proxy).
  2. Port 25 reachable from the Internet. Many home connections block it: check with your provider.
  3. Docker, or Debian 12 (or newer) to build from source.

The server listens on IPv4 only.

INSTALLATION

Pick one of the three ways. All of them keep their data in MAILFOLDER: put it on a persistent volume.

1. Docker, ports open directly

The image is published on Docker Hub as loweel/zangtumb:latest:

docker pull loweel/zangtumb:latest

The simplest setup: the container's ports are the host's. See docker-compose.example:

services:
  zangtumb:
    image: loweel/zangtumb:latest
    restart: unless-stopped
    environment:
      - DOMAINNAME=example.com
      - MAILUSER=me
      - MAILPASSWORD=change-me
      - MAILFOLDER=/zangmail
      - SMTP_LISTEN=:25
      - IMAP_LISTEN=:143
      - DAV_ENABLED=true
      - DAV_LISTEN=:8088
      - GRAYLISTING_ENABLED=true
      - GRAYLISTING_DIR=/zangmail/graylist
      - TZ=Europe/Berlin
    ports:
      - "25:25"
      - "143:143"
      - "127.0.0.1:8088:8088"   # DAV: put an HTTPS proxy in front of it
    volumes:
      - ./mail_data:/zangmail
      - ./certs:/opt/zangtumb/certs
docker compose -f docker-compose.example up -d
docker compose -f docker-compose.example logs -f

The image runs as root, so it can bind ports 25 and 143. If you run it as another user (user: "1000:1000"), listen on high ports inside the container (SMTP_LISTEN=:30025, IMAP_LISTEN=:30143) and map 25 and 143 to them.

IMAP on 143 offers STARTTLS with the server's certificate. If you want implicit TLS on 993 with a real certificate, put a proxy in front: see the next way.

2. Behind Traefik, with the PROXY protocol

Behind Traefik (or swarm's ingress) every connection seems to come from a few internal addresses: the log, the Received headers and the count of wrong passwords would see the proxy, not the client. With the PROXY protocol the proxy tells ZangTumb who the client is.

Traefik's dynamic configuration, a file provider (see traefik-tcp.example.yml):

tcp:
  routers:
    smtp:
      entryPoints: ["smtp"]               # :25
      rule: "HostSNI(`*`)"                # no TLS here: STARTTLS is ZangTumb's
      service: "smtp-svc"
    imaps:
      entryPoints: ["imaps"]              # :993
      rule: "HostSNI(`mail.example.com`)"
      tls:
        certResolver: "letsencrypt"       # Traefik ends TLS for IMAP
      service: "imap-svc"

  services:
    smtp-svc:
      loadBalancer:
        proxyProtocol:
          version: 2
        servers:
          - address: "192.168.1.10:30025"
    imap-svc:
      loadBalancer:
        proxyProtocol:
          version: 2
        servers:
          - address: "192.168.1.10:30143"

and ZangTumb's environment, beside the settings of way 1:

      - SMTP_LISTEN=:30025
      - IMAP_LISTEN=:30143
      - SMTP_PROXY_PROTOCOL=true
      - IMAP_PROXY_PROTOCOL=true
  • SMTP must pass through Traefik untouched (HostSNI(*), no tls:): the STARTTLS and the client certificate check are ZangTumb's.
  • IMAP can be ended by Traefik on 993 with a Let's Encrypt certificate; ZangTumb then speaks plain IMAP to Traefik.
  • With Traefik v3.2 or later, proxyProtocol can also go in a serversTransport; the form above still works.
  • In a swarm, every server listed must answer on those ports: Traefik picks them in turn, and one that does not answer loses one connection in so many.

Switch it on in both together. A ZangTumb that does not expect the header reads it as broken commands (in SMTP it even says QUIT), and one that requires it closes the connections that lack it. To switch without a gap: set both variables to optional (ZangTumb reads a header when one comes, a connection without one waits a second and is served), switch on Traefik's proxyProtocol, then set them to true.

Only the proxy may reach those ports. The header is believed: whoever can connect to 30025 or 30143 directly can claim any address.

Check it in the log: remote= shows the client's public address, and with DEBUG=true each connection logs proxy=<the proxy> client=<the client>.

3. From source

On Debian 12 or newer:

sudo apt-get install gnat gprbuild make gcc \
  libssl-dev libetpan-dev libmicrohttpd-dev libxml2-dev ca-certificates
git clone https://git.keinpfusch.net/loweel/zangtumb.git
cd zangtumb
make

The program is bin/zangtumb, the GNAT runtime linked in; it needs the libraries' runtime packages (libssl3 libetpan20 libmicrohttpd12 libxml2) and ca-certificates. Set the environment (see Configuration) and run it:

DOMAINNAME=example.com MAILUSER=me MAILPASSWORD=change-me \
MAILFOLDER=/var/lib/zangtumb SMTP_LISTEN=:25 IMAP_LISTEN=:143 \
./bin/zangtumb

Ports 25 and 143 need root or CAP_NET_BIND_SERVICE.

CONFIGURATION

ZangTumb is configured with environment variables only.

Variable Default Meaning
DOMAINNAME (required) The one domain mail is received for.
MAILUSER (required) The one user: every *@DOMAINNAME ends up in its mailbox. IMAP and DAV login.
MAILPASSWORD (required) Password for IMAP and DAV.
MAILFOLDER ./mail Root of the storage: mail and DAV data. Keep it persistent.
SMTP_LISTEN :25 SMTP address, host:port or :port.
SMTP_SESSIONS 100 SMTP sessions served at once.
SMTP_CLIENT_CA_FILE (none) One more authority, a PEM file, to trust for client certificates, beside the system's.
SMTP_PROXY_PROTOCOL (off) true: a PROXY header (v1 or v2) is required on SMTP connections; optional: read when it comes; empty or false: none.
IMAP_LISTEN :143 IMAP address.
IMAP_SESSIONS 50 IMAP sessions served at once.
IMAP_PROXY_PROTOCOL (off) The same as SMTP_PROXY_PROTOCOL, for IMAP.
IMAP_IDLE_KEEPALIVE 120s During IDLE, an * OK line this often, so a balancer in front does not close a quiet connection.
CERTFILE ./certs/DOMAINNAME.crt Server certificate (PEM, with its chain). Made self-signed if missing.
KEYFILE ./certs/DOMAINNAME.key Its key. Made if missing.
GRAYLISTING_ENABLED false true turns graylisting on.
GRAYLISTING_DIR /tmp/zangtumb_graylist Directory of the graylisting records.
GRAYLISTING_DB_PATH (none) From version 2: without GRAYLISTING_DIR, the records go in this path plus .d. The old SQLite file is not read.
GRAYLISTING_DELAY 30s How long a new sender must wait before trying again.
GRAYLISTING_EXPIRY 36h How long a server is remembered after its last delivery, or after a first try it never came back to.
DAV_ENABLED false true turns CalDAV/CardDAV on.
DAV_LISTEN :8088 DAV's HTTP address.
MAX_MESSAGE_SIZE 10485760 Largest message, in bytes, for SMTP and IMAP APPEND.
DEBUG false true logs every line of every session, parts of messages included. For finding a problem, not for every day.
TZ (UTC) Time zone of the log and of the Received headers, e.g. Europe/Berlin.

Durations take h, m, s and ms, combined if you like: 30s, 36h, 1h30m.

HOW IT BEHAVES

Who may deliver

The sending server must say STARTTLS before MAIL, and it must show a client certificate that is valid: not expired, and signed, through its whole chain, by an authority the system trusts (Debian's ca-certificates, in /etc/ssl/certs) or by the one in SMTP_CLIENT_CA_FILE. The name in it is not checked, nor its purpose: the certificate keeps spam engines out, it does not authenticate the sender, so a server certificate without clientAuth (Let's Encrypt's, since 2026) is accepted, logged with eku=server-only. Gmail, GMX, Office 365 and the other big providers do this; spam engines rarely do. A server that shows none, or one that is not valid, is refused and logged as an error with the reason.

ZangTumb's own certificate can stay self-signed: senders do not check the certificate of the server they deliver to.

Relay attempts

A recipient outside the domain is a relay attempt: it waits ten seconds and is told to try again later (451). It comes back, and waits again.

Graylisting

A sending server is known by its client certificate, already verified, by the certificate's SHA-256 fingerprint (as openssl x509 -fingerprint -sha256 shows it), whatever the sender and the recipient. A certificate's first try gets a 451 and is remembered; a try after GRAYLISTING_DELAY passes, and from then on every message with that certificate passes at once. Every delivery renews the record; a certificate unused for longer than GRAYLISTING_EXPIRY, or a new one after a renewal, waits once.

One file per certificate in GRAYLISTING_DIR, named by its fingerprint and holding two times; the log shows the first 16 characters of the fingerprint as cert=.

Wrong IMAP passwords

Every wrong password from the same address waits longer than the one before, in seconds as Fibonacci goes: 1, 1, 2, 3, 5, 8... A right password, or a day without wrong ones, starts the count again. Behind a proxy, use the PROXY protocol: without it every client has the proxy's address and shares its count.

CalDAV and CardDAV

With DAV_ENABLED=true, one calendar and one address book, with the same user and password as IMAP:

/.well-known/caldav     ->  /calendars/MAILUSER/default/
/.well-known/carddav    ->  /contacts/MAILUSER/default/

DAV speaks plain HTTP with Basic authentication on every route, /health included: put an HTTPS proxy in front of it. Clients find the collections from the server's address (https://cal.example.com/). A whole .ics file can be imported with a POST to the calendar collection.

Storage

MAILFOLDER/
└── MAILUSER/
    ├── Maildir/                 INBOX: new/ cur/ tmp/
    │   ├── .Archive/            a mailbox "Archive" (Maildir++)
    │   ├── .zangtumb-uidmap     the UIDs of INBOX
    │   └── subscriptions
    └── dav/
        ├── calendars/default/calendar.ics
        └── contacts/default/contacts.vcf

Flags are in the file names (:2,S read, F flagged...), as Maildir does. Back up MAILFOLDER and you have everything.

Logging

On standard error, as 2026/11/14 16:34:59 [LEVEL] message:

  • ERROR: something failed that should not have: a file that cannot be written, a sender without a valid certificate, a PROXY header missing where one is required. Read these.
  • WARN: the other side misbehaved: a password wrong, a relay attempt, a line too long, a connection dropped.
  • INFO: deliveries, logins, starts.
  • DEBUG, with DEBUG=true: every line of every session.

UPGRADING FROM VERSION 2 (GO)

Same variables, same files: point version 3 at the same MAILFOLDER and volumes, and use the image loweel/zangtumb:latest. Mail, flags, UIDs (clients do not download again), mailboxes, subscriptions, calendar and contacts carry over, and version 2 reads them back if you go back. Two differences:

  • The graylist starts empty, and is kept by client certificate, not by pair: each server is graylisted once more, then never while it keeps writing with the same certificate.
  • Client certificates must now be valid; version 2 took any.

Version 2's code is in the branch old-go.

DEVELOPMENT

make                      # bin/zangtumb
python3 smoketest.py      # the black-box tests (python3 smoketest.py 1 2 18: those only)
make prove                # the SPARK proofs, with gnatprove

Drone runs the smoke tests on Debian 12 for every push to master, then builds the image, pushes it to Docker Hub as latest and as the commit, and updates the service.

FAQ

  • Why is it a Catch-All server?

  • Because managing multiple mailboxes is for people with too much free time. You own your domain.
    One domain, one user, maximum speed.

  • Why don't you use OpenSMTPD?

  • Because making this server took less effort than containerizing OpenSMTPD properly.

  • Why don't you use Postfix/Sendmail/Qmail/Courier?

  • I host four mailboxes in total. Why should I deploy all that complexity?
    Complexity != security.

  • !ZangTumb forces StartTLS. This is against the RFC!!!!

  • Unfortunately, English cannot properly translate the correct Italian answer, which would roughly be: "Esticazzi?"

  • This Ada code is not idiomatic. And there is no graphene, no quantum computing, no UI/UX, and no horizontally scalable Internet of Things powered by Artificial Intelligence and Big Data.

  • Please, bring me a Frappuccino.

  • Why you expect the sender server has a client certificate!!! You evil!!!!

  • Is perfectly reasonable. In real life, the equivalent would be that only real couriers and national post service can put paper in your mailbox. Reasonable and legit, IMHO.