Postfix SMTP relay docker image. Useful for sending email without using an external SMTP server.
docker pull mwader/postfix-relay
or clone and build it yourself. Default
postfix is configured to be an open relay that rely on docker networking
for firewalling. So be careful not to expose it publicly.
All postfix configuration options can be set using POSTFIX_<name>
environment
variables. See Dockerfile for default configuration. You probably
want to set POSTFIX_myhostname
, the FQDN used by 220/HELO.
docker run \
-e POSTFIX_myhostname=smtp.domain.tld \
--name smtp \
mwader/postfix-relay
app:
# use hostname "smtp" as SMTP server
smtp:
image: mwader/postfix-relay
restart: always
environment:
- POSTFIX_myhostname=smtp.domain.tld
When sending email using your own SMTP server it is probably a very good idea to setup SPF for the domain your sending from.
To enable DKIM
specifying a white space separated list of domains in the environment variable
OPENDKIM_DOMAINS
. At container start key pairs for each domain will be
generated if not found in /etc/opendkim/keys/<domain>
. To persist the keys make
sure to add a host directory volume for /etc/opendkim/keys
. If your using
docker-compose it will automatically take care of moving data volumes between
container recreates.
DNS records to configure can be found in the container log or by running
docker exec <container> cat /etc/opendkim/keys/*/mail.txt
.
postfix-relay is licensed under the MIT license. See LICENSE for the full license text.