I am trying to configure an SMTP Relay Docker container obtained from https://hub.docker.com/r/turgon37/smtp-relay for use by another container in the same network to send outgoing emails to an external SMTP server. This SMTP Relay container simply comprises postfix and its dependencies, and configures postfix to act as a a SMTP Relay.
A simple looking example on that page includes a domain name. But domains do not appear to be a concept that sits well with docker containers, and to make things worse is one of the few mandatory settings, and its summary description is also far from clear.
(Unfortunately, although the author has obviously done a well thought out and careful job on this, I don't think English is his native language, and some of the summary descriptions are somewhat ambiguous and baffling and may mean the opposite of what I assume! )
My docker-compose config comprises the following, in which I assume (but am ready to be corrected!) that RELAY_HOST is the hostname or IP address of the remote server to which the relay is to send outgoing emails. If it helps, only the "django_fred" container will be sending outgoing emails.
version: '3.3'
services:
application:
image: fred:latest
container_name: django_fred
build:
context: ./application
ports:
- "8000:8000"
depends_on:
- postgres
- cassandra
networks:
- frednet
postgres:
image: postgres:9.6.10
container_name: postgres_fred
networks:
- frednet
cassandra:
build:
dockerfile: Dockerfile
context: ./cassandra
image: fred/cassandra:yaml
container_name: cassandra_fred
networks:
- frednet
smtp-relay:
image: turgon37/smtp-relay:latest
container_name: smtp_relay
environment:
- RELAY_MYHOSTNAME=smtp_relay <-- is this correct/acceptable ?
- RELAY_MYDOMAIN=frednet.com <-- mandatory, but is this correct ?!
- RELAY_MYNETWORKS=frednet <-- is this correct ?
- RELAY_HOST=195.194.167.24:25
ports:
- "25:25"<-- example includes an IP address in \
- "587:587"<-- square brackets, but is that needed ?! \
networks: <-- Also, why does it differ from RELAY_HOST ?!
- frednet:
networks:
frednet:
and the example referred to above is as follows:
* unauthenticated smtp relay filtered by subnet and domain name
services:
smtp-relay:
image: turgon37/smtp-relay:latest
environment:
- RELAY_POSTMASTER=postmaster@example.net
- RELAY_MYHOSTNAME=smtp-relay.example.net
- RELAY_MYDOMAIN=example.net
- RELAY_MYNETWORKS=127.0.0.0/8 10.0.0.0/24
- RELAY_HOST=[10.1.0.1]:25
ports:
- "10.0.0.1:3000:25"
Apart from my questions marked by "<--" in the Docker config above I'd like to understand why there is an IP address in the "ports:" entry at the end of the example, and where/why does port 3000 come into it?
Any ideas? TIA