Sign inSign up

jchonig/postfix

By jchonig

Updated 6 days ago

Postfix running in a docker container to be used as a mail relay

Image
0

10K+

jchonig/postfix repository overview

docker-postfix

A container running postfix intended to be used as an internal mail relay to the outside world.

Image hosted at: ghcr.io/jchonig/postfix

Optionally authenticate incoming connections with SASL

Usage

docker

docker create \
  --name=posfix \
  -e PUID=1000 \
  -e PGID=1000 \
  -v </path/to/appdata/config>:/config \
  -p 25:25 \
  --restart unless-stopped \
  ghcr.io/jchonig/postfix
docker-compose

Compatible with docker-compose v2 schemas.

---
version: "2"
services:
  postfix:
    image: ghcr.io/jchonig/postfix
    environment:
      - PUID=1000
      - PGID=1000
    volumes:
      - </path/to/appdata/config>:/config
	  - data:/data
    port:
      - 25
    restart: unless-stopped

volumes:
  data:

Parameters

Ports (-p)

VolumeFunction
25The incoming SMTP port

Environment Variables (-e)

EnvFunction
PUID=1000for UserID - see below for explanation
PGID=1000for GroupID - see below for explanation
USE_SASL=yesUse sasl for user authentication
USE_SASLAUTHD=yesUse saslauthd
USE_DKIM=yesNot yet implemented
USE_TLS=yesEnable STARTTLS for incoming connections on port 25
USE_SMTPS=yesEnable TLS wrapper on port 465
MYHOSTNAME=example.comConfigure postfix myhostname parameter
MYORIGIN=example.comConfigure postfix myorigin parameter
MYDESTINATION=Configure postfix mydestination parameter
MASQUERADE_DOMAINS=example.comA comma seperated list of domains to masquerade
SMTPD_TLS_SECURITY_LEVEL=mayConfigure the level of TLS required on incomming connections
BOUNCE_QUEUE_LIFETIME=1dConfigure the postfix bounce queue lifetime
INET_PROTOCOLS=allSet postfix inet_protocols (e.g. all, ipv4, ipv6)
RELAYHOST=[host]:portOutbound relay host (e.g. [smtp-relay.gmail.com]:587)

Volume Mappings (-v)

VolumeFunction
/dataPersistent data (i.e. /data/spool)
/configAll the config files reside here

Application Setup

  • When USE_TLS is enabled, /config/server.cert and /config/server.key should exist
    • When these files are updated, postfix is reloaded automatically
  • When RELAYHOST is set, outbound TLS (smtp_tls_security_level=encrypt) is enabled automatically
    • Relay credentials are read from /config/sasl.passwd, which uses standard postfix sasl_passwd format: one entry per line of relayhost user:password
    • Example: [smtp-relay.gmail.com]:587 [email protected]:app-password
    • /config/sasl.passwd is read directly by postfix on demand — no rebuild step needed when the file changes
    • For Gmail Workspace: set RELAYHOST=[smtp-relay.gmail.com]:587 and generate an App Password for the account; enable the SMTP relay service in Google Workspace Admin → Apps → Gmail → Routing
  • When using SASL, /config/sasl.users should should have one entry per line of user and password seperated by a space
    • WHen this file is updated, update_sasldb_users is run automatically
  • Additonal postfix configuration can be stored in /config/postconf and /config/postconf.d/*
    • These files contain arguments to the postconf command
    • These files are processed when the container starts
    • These files are reparsed automatically when they are modified or created
    • The files in /config/postconf.d are not processed in a particular order
  • Aliases are stored in /config/aliases
    • If this file does not exists the default postfix file is copied to it
    • When this file is updated, newaliases is run

TODO

  • Set up DKIM
  • Read and process generics and virtual? ...

Tag summary

Content type

Image

Digest

sha256:2f3290358

Size

30.1 MB

Last updated

6 days ago

docker pull jchonig/postfix