Set up Postfix to relay local emails over the internet
8.8K
This Docker image sets up Postfix inside a docker container.
Postfix is a free and open-source mail transfer agent (MTA) that routes and delivers electronic mail.
To use docker-postfix, follow these steps:
Clone and start the container:
docker run -p 25:25 \
-e POSTFIX_HOSTNAME=mail.example.com \
-e POSTFIX_RELAYSERVER=smtp.mail.com \
-e [email protected] \
-e POSTFIX_RELAYPASS=123456 \
docker.io/aguslr/postfix:latest
Configure your systems to send email to your Postfix server's IP address on
port 25.
The image is configured using environment variables passed at runtime. All these
variables are prefixed by POSTFIX_.
| Variable | Function | Required |
|---|---|---|
HOSTNAME | Hostname for the container | Y |
DOMAIN | Domain name for Postfix | N |
RELAYSERVER | Address of the SMTP server to use | Y |
RELAYPORT | Port to connect to the SMTP server | N |
RELAYUSER | Username of SMTP server | Y |
RELAYPASS | Password of SMTP server | N |
OVERWRITE | Use this from address for all relayed emails | N |
FROM | Rewrite from address | N |
TO | Rewrite to address | N |
DESTINATION | List of domains allowed to use relay server | N |
NETWORKS | List of networks allowed to use relay server | N |
As an alternative to passing the relay's server password at runtime, we can use
a password file (e.g. passwd) with the format:
[RELAYSERVER]:RELAYPORT RELAYUSER:RELAYPASS
We can then mount this file at runtime with this command:
docker run -p 25:25 \
-e POSTFIX_HOSTNAME=mail.example.com \
-e POSTFIX_RELAYSERVER=smtp.mail.com \
-e [email protected] \
-v "${PWD}"/passwd:/etc/postfix/sasl_passwd \
docker.io/aguslr/postfix:latest
Instead of pulling the image from a remote repository, you can build it locally:
Clone the repository:
git clone https://github.com/aguslr/docker-postfix.git
Change into the newly created directory and use docker-compose to build and
launch the container:
cd docker-postfix && docker-compose up --build -d
Content type
Image
Digest
sha256:1a945d059…
Size
53.1 MB
Last updated
23 days ago
docker pull aguslr/postfix