Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v5
with:
submodules: true

- name: Get repo name
id: image_name
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ RUN set -x \
&& mkdir /etc/opendkim/ \
;

COPY header_checks /etc/postfix/header_checks
COPY opendkim.conf.sh /etc/
COPY etc/header_checks /etc/postfix/header_checks
COPY etc/opendkim.conf.sh /etc/
COPY --from=postfix_exporter /go/bin/postfix_exporter /usr/local/bin/postfix_exporter
COPY s6 /etc/s6/
COPY etc/s6 /etc/s6/
COPY entry.sh /

RUN set -x \
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 - 2025 Volt Grid Pty Ltd
Copyright (c) 2015 - 2026 Volt Grid Pty Ltd

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ run-dkim: dkim.key ## Runs the docker image in a test mode with DKIM
-e RELAYHOST=172.17.0.2 \
-e MAILNAME=mail.example.com \
-e CONFIG_RELOADER_ENABLED=true \
-e USE_DKIM=yes -v `pwd`/dkim.key:/etc/opendkim/dkim.key $(IMAGE_NAME):$(TAG)))
-e USE_DKIM=yes -v $(shell pwd)/dkim.key:/etc/opendkim/dkim.key $(IMAGE_NAME):$(TAG)))
$(eval IP := $(shell docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${ID}))
@echo "Running ${ID} @ smtp://${IP}"
@docker attach ${ID}
Expand All @@ -40,7 +40,7 @@ run-all-dkim: dkim.key ## Runs the docker image in a test mode. All settings
-e MAILNAME=mail.example.com \
-e DKIM_DOMAINS=foo.example.com,bar.example.com,example.net \
-e DKIM_SELECTOR=6091aa68-f43d-47cf-a52e-bafda525d0bc \
-e USE_DKIM=yes -v `pwd`/dkim.key:/etc/opendkim/dkim.key $(IMAGE_NAME):$(TAG)))
-e USE_DKIM=yes -v $(shell pwd)/dkim.key:/etc/opendkim/dkim.key $(IMAGE_NAME):$(TAG)))
$(eval IP := $(shell docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${ID}))
@echo "Running ${ID} @ smtp://${IP}"
@docker attach ${ID}
Expand Down
44 changes: 41 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Postfix Docker Image

![build-push](https://github.com/panubo/docker-postfix/actions/workflows/build-push.yml/badge.svg)
[![release](https://img.shields.io/github/v/release/panubo/docker-postfix)](https://github.com/panubo/docker-postfix/releases/latest)
[![license](https://img.shields.io/github/license/panubo/docker-postfix)](LICENSE)

Postfix SMTP Relay based on Debian Bullseye.

Highly configurable Docker image for SMTP relaying. Use wherever a connected service
Expand All @@ -11,6 +15,20 @@ email access.

This image is available on quay.io `quay.io/panubo/postfix` and AWS ECR Public `public.ecr.aws/panubo/postfix`.

## Table of Contents

- [Environment Variables](#environment-variables)
- [Postfix Prometheus Exporter](#postfix-prometheus-exporter)
- [Logging](#logging)
- [Custom Scripts](#custom-scripts)
- [Usage Example](#usage-example)
- [Volumes](#volumes)
- [Ports](#ports)
- [Test email](#test-email)
- [Developing](#developing)
- [Releases](#releases)
- [Status](#status)

## Environment Variables

- `MAILNAME` - set this to a legitimate FQDN hostname for this service (required). (example, `mail.example.com`)
Expand Down Expand Up @@ -84,7 +102,7 @@ In some cases it might be necessary to further customise Postfix parameters that

Example usage:

```
```shell
POSTCONF=masquerade_domains=foo.example.com example.com;masquerade_exceptions=root,mailer-daemon
```

Expand Down Expand Up @@ -128,7 +146,7 @@ Simple example:

Usage with SendGrid:

```
```shell
docker run --rm -t -i \
--name smtp \
-v $(pwd)/spool:/var/spool/postfix:rw \
Expand All @@ -139,6 +157,21 @@ docker run --rm -t -i \
quay.io/panubo/postfix:latest
```

Usage with `docker-compose.yml`:

```yaml
services:
postfix:
image: quay.io/panubo/postfix:latest
environment:
MAILNAME: mail.example.com
RELAYHOST: '[smtp.sendgrid.net]:587'
RELAYHOST_AUTH: 'yes'
RELAYHOST_PASSWORDMAP: '[smtp.sendgrid.net]:587:apikey:YOUR_API_KEY'
ports:
- "2525:25"
```

## Volumes

No volumes are defined. If you want persistent spool storage then mount
Expand All @@ -152,7 +185,7 @@ Ports `25`, `587` and `2525` are enabled.

To send a test email via the command line, make sure heirloom-mailx (aka bsd-mailx) is installed.

```
```shell
echo -e "To: Bob <bob@example.com>\nFrom: Bill <bill@example.com>\nSubject: Test email\n\nThis is a test email message" | mailx -v -S smtp=smtp://... -S from=bill@example.com -t

# With TLS
Expand All @@ -173,6 +206,11 @@ For production usage, please use a versioned release rather than the floating 'l
See the [releases](https://github.com/panubo/docker-postfix/releases) for tag usage
and release notes.

Images are available on:

- [quay.io/panubo/postfix](https://quay.io/repository/panubo/postfix?tab=tags)
- [public.ecr.aws/panubo/postfix](https://gallery.ecr.aws/panubo/postfix)

## Status

Production ready and stable.
File renamed without changes.
10 changes: 7 additions & 3 deletions opendkim.conf.sh → etc/opendkim.conf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ if [ ! -f "${DKIM_KEYFILE}" ]; then
s6-svscanctl -t /etc/s6
exit 128
else
echo "dkim >> Setting mode and owner on $DKIM_KEYFILE"
chown root:root ${DKIM_KEYFILE}
chmod 400 ${DKIM_KEYFILE}
echo "dkim >> Checking mode and owner on $DKIM_KEYFILE"
if [ "$(stat -c "%U:%G" "${DKIM_KEYFILE}")" != "root:root" ]; then
chown root:root "${DKIM_KEYFILE}" || { echo "dkim >> Warning: could not set owner on DKIM_KEYFILE"; }
fi
if [ "$(stat -c "%a" "${DKIM_KEYFILE}")" != "400" ]; then
chmod 400 "${DKIM_KEYFILE}" || { echo "dkim >> Warning: could not set mode on DKIM_KEYFILE"; }
fi
fi

# Status Output
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.