Sign inSign up

aguslr/postfix

By aguslr

•Updated 1 day ago

Set up Postfix to relay local emails over the internet

Image
0

9.6K

aguslr/postfix repository overview

⁠aguslr/docker-postfix⁠

docker-pulls image-size

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.

⁠Installation

To use docker-postfix, follow these steps:

  1. 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
    
  2. Configure your systems to send email to your Postfix server's IP address on port 25.

⁠Variables

The image is configured using environment variables passed at runtime. All these variables are prefixed by POSTFIX_.

VariableFunctionRequired
HOSTNAMEHostname for the containerY
DOMAINDomain name for PostfixN
RELAYSERVERAddress of the SMTP server to useY
RELAYPORTPort to connect to the SMTP serverN
RELAYUSERUsername of SMTP serverY
RELAYPASSPassword of SMTP serverN
OVERWRITEUse this from address for all relayed emailsN
FROMRewrite from addressN
TORewrite to addressN
DESTINATIONList of domains allowed to use relay serverN
NETWORKSList of networks allowed to use relay serverN
⁠Password file

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

⁠Build locally

Instead of pulling the image from a remote repository, you can build it locally:

  1. Clone the repository:

    git clone https://github.com/aguslr/docker-postfix.git
    
  2. Change into the newly created directory and use docker-compose to build and launch the container:

    cd docker-postfix && docker-compose up --build -d
    

Tag summary

Content type

Image

Digest

sha256:20e40096f…

Size

50.4 MB

Last updated

1 day ago

docker pull aguslr/postfix