I would like to host several automatic email services in docker containers that send and receive emails through the Postfix server, which is also in a container. The only outward-facing container hosts nginx proxy manager. A docker network links all the containers together. I streamed port 25
in the nginx proxy manager to the Postfix container.
Since I am either sending or receiving emails for the services within the internal network, I added my internal network range to main.cf
mynetwork = 172.16.0.0/12
The problem quickly emerged as I realized that other random senders were relaying spam emails through my domain. The reason is that when streaming using the proxy manager, Postfix always sees the incoming email as from the proxy, and is thus recognized as being sent from my local network, and sends it regardless.
The current solution involves entering the configuration one by one
mynetwork = service-1 service-2 ...
The problem is that if I were to add more services to my server, I would have to change the config files manually and restart Postfix service. Is there a way to exclude certain hosts from the permission list in the Postfix config like so?
mynetwork = 172.16.0.0/12 exclude:[host-name-to-exclude]
Many thanks!
permit_mynetworks
?mynetwork
.apt-get update
in a container.