Simple SMTP relay docker image.
Find a file
2015-05-13 01:08:58 -05:00
etc/supervisord.d Postfix configuration file for supervisord. 2015-04-19 17:30:19 -05:00
Dockerfile Run newaliases too. 2015-05-12 02:20:38 -05:00
README.md Add SERVER_HOSTNAME env var to example. 2015-05-13 01:08:58 -05:00
run.sh Set myhostname and myorigin, some providers like 1&1 will do MX lookups on them so they need to be valid. 2015-05-13 01:06:38 -05:00

docker-postfix

Simple Postfix SMTP TLS relay docker image with no local authentication enabled (to be run in a secure LAN).

Build instructions

Clone this repo and then:

cd docker-Postfix
sudo docker build -t postfix .

You can also find a prebuilt docker image from Docker Hub, which can be pulled with this command:

sudo docker pull juanluisbaptiste/postfix:latest

How to run it

The following env variables need to be passed to the container:

  • SMTP_SERVER Server address of the SMTP server to use.
  • SMTP_USERNAME Username to authenticate with.
  • SMTP_PASSWORD Password of the SMTP user.
  • SERVER_HOSTNAME Server hostname for the Postfix container. Emails will appear to come from the hostname's domain.

To use this container from anywhere, the 25 port needs to be exposed to the docker host server:

docker run -d --name postfix -p "25:25"  \ 
       -e SMTP_SERVER=smtp.bar.com \
       -e SMTP_USERNAME=foo@bar.com \
       -e SMTP_PASSWORD=XXXXXXXX \
       -e SERVER_HOSTNAME=helpdesk.mycompany.com \
       juanluisbaptiste/postfix

If you are going to use this container from other docker containers then it's better to just publish the port:

docker run -d --name postfix -P \
       -e SMTP_SERVER=smtp.bar.com \
       -e SMTP_USERNAME=foo@bar.com \
       -e SMTP_PASSWORD=XXXXXXXX \
       juanluisbaptiste/postfix

A note about using gmail as a relay

Since last year, Gmail by default does not allow email clients that don't use OAUTH 2 for authentication (like Thunderbird or Outlook). First you need to enable access to "Less secure apps" on your google settings.

Also take into account that email From: header will contain the email address of the account being used to authenticate against the Gmail SMTP server(SMTP_USERNAME), the one on the email will be ignored by Gmail.