diff --git a/README.md b/README.md index 5ecec55e..f3b5af4f 100644 --- a/README.md +++ b/README.md @@ -141,3 +141,10 @@ Otherwise, `iptables` won't be able to ban IPs. - self-signed => Enables self-signed certificates Please read [the SSL page in the wiki](https://github.com/tomav/docker-mailserver/wiki/Configure-SSL) for more information. + +##### PERMIT_DOCKER + +Set different options for mynetworks option (can be overwrite in postfix-main.cf) + - **empty** => localhost only + - host => Add docker host (ipv4 only) + - network => Add all docker containers (ipv4 only) diff --git a/target/postfix/main.cf b/target/postfix/main.cf index 1b77a283..158cfa17 100644 --- a/target/postfix/main.cf +++ b/target/postfix/main.cf @@ -11,7 +11,7 @@ alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases mydestination = relayhost = -mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 172.17.0.0/16 +mynetworks = 127.0.0.0/8 [::1]/128 [fe80::]/64 mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all diff --git a/target/start-mailserver.sh b/target/start-mailserver.sh index 037332f9..6e225a97 100644 --- a/target/start-mailserver.sh +++ b/target/start-mailserver.sh @@ -202,6 +202,25 @@ echo "Postfix configurations" touch /etc/postfix/vmailbox && postmap /etc/postfix/vmailbox touch /etc/postfix/virtual && postmap /etc/postfix/virtual +# My Network Configuration +case $PERMIT_DOCKER in + "host" ) + echo "Adding host in my networks" + postconf -e "$(postconf -d | grep '^mynetworks =')" + ;; + + "network" ) + echo "Adding docker network in my networks" + postconf -e "$(postconf | grep '^mynetworks =') 172.0.0.0/8" + ;; + + * ) + echo "Adding container ip in my networks" + postconf -e "$(postconf | grep '^mynetworks =') $(ip addr show eth0 | grep 'inet ' | sed 's/[^0-9\.\/]*//g' | cut -d '/' -f 1)/32" + ;; + +esac + # # Override Postfix configuration #