OK so here is what I’ve done to make postfix listen to my docker container:
add/change the following lines to /etc/postfix/main.cfg:
- mynetworks = add the IP address range of your nextcloud docker container e.g. 172.24.0.0/16
Tip: add the folowing to your docker-compose.yml to add a static IP address subnet to your docker container:
networks:
nextcloud_network:
ipam:
config:
- subnet: 172.24.0.0/16
- inet_interfaces = add the IP address of your docker0 interface e.g. 172.17.0.1
(user ip addr show of ifconfig and note the IP address corresponding to docker0, you don’t need to enter the mask e.g. /16)
Then restart your postfix service (e.g. sudo service postfix restart). If you have a firewall like ufw or iptables active, make sure you add rules to accept connections from your Nextcloud container IP to port 25.
Now you can add add the following to your Nextcloud config.php:
'mail_domain' => 'mail.com',
'mail_from_address' => 'my.cloud',
'mail_smtpmode' => 'smtp',
'mail_sendmailmode' => 'smtp',
'mail_smtpport' => '25',
'mail_smtphost' => '172.17.0.1', //the IP address of docker0
For server address use the IP address of your docker0 interface and all should work