Commit f921020c by Daniel Marinovici

refs #28587 Configure for generic usage of postfix, not only as relay; use…

refs #28587 Configure for generic usage of postfix, not only as relay; use centos6 to start postfix service
parent c1c31b23
FROM layerworx/centos FROM centos:6
RUN yum -y install postfix mailx cyrus-sasl cyrus-sasl-plain python-setuptools python-pip rsyslog RUN yum -y install postfix mailx cyrus-sasl cyrus-sasl-plain python-setuptools python-pip rsyslog
...@@ -6,4 +6,4 @@ VOLUME ["/var/log"] ...@@ -6,4 +6,4 @@ VOLUME ["/var/log"]
ADD postfix.sh /postfix.sh ADD postfix.sh /postfix.sh
CMD ["sh", "-c", "./postfix.sh"] CMD ["sh", "-c", "/postfix.sh"]
\ No newline at end of file
...@@ -4,9 +4,9 @@ Available tags: [latest](https://github.com/eea/eea.docker.postfix/blob/master/D ...@@ -4,9 +4,9 @@ Available tags: [latest](https://github.com/eea/eea.docker.postfix/blob/master/D
This image is a CentOS 6 container running postfix preconfigured for SMTP relay authentication. It runs as an open relay mail server inside the Docker Containers internal network, so it can be used by any container to send emails through the remote relay. This image is a CentOS 6 container running postfix preconfigured for SMTP relay authentication. It runs as an open relay mail server inside the Docker Containers internal network, so it can be used by any container to send emails through the remote relay.
The relay is set in the environment variable: `MTP_RELAY`. The hostname of the postfix server is set in the environment variable `MTP_HOST` and is mandatory. Postfix will run as an open relay server only if the variables below are also set.
The hostname of the postfix server is set in: `MTP_HOST`. The relay is set in `MTP_RELAY` and the port in `MTP_PORT`.
The `.secrets` file should be used as a runtime environment variables, to set the user and password required for SMTP authentication by the `MTP_RELAY`: The `.secrets` file should be used as a runtime environment variables, to set the user and password required for SMTP authentication by the `MTP_RELAY`:
......
FROM layerworx/centos FROM centos:6
RUN yum install -y mailx ssmtp RUN yum install -y mailx ssmtp
......
...@@ -2,20 +2,25 @@ ...@@ -2,20 +2,25 @@
# Set up user # Set up user
function setup_conf_and_secret { function setup_conf_and_secret {
postconf -e "myhostname = $MTP_HOST"
postconf -e "relayhost = [$MTP_RELAY]:$MTP_PORT" postconf -e "relayhost = [$MTP_RELAY]:$MTP_PORT"
postconf -e 'smtp_sasl_auth_enable = yes' postconf -e 'smtp_sasl_auth_enable = yes'
postconf -e 'smtp_sasl_password_maps = hash:/etc/postfix/relay_passwd' postconf -e 'smtp_sasl_password_maps = hash:/etc/postfix/relay_passwd'
postconf -e 'smtp_sasl_security_options = noanonymous' postconf -e 'smtp_sasl_security_options = noanonymous'
postconf -e 'smtp_tls_security_level = may' postconf -e 'smtp_tls_security_level = may'
postconf -e 'mynetworks = 127.0.0.0/8 172.17.0.0/16' postconf -e 'mynetworks = 127.0.0.0/8 172.17.0.0/16'
postconf -e 'inet_interfaces = all'
echo "$MTP_RELAY $MTP_USER:$MTP_PASS" > /etc/postfix/relay_passwd echo "$MTP_RELAY $MTP_USER:$MTP_PASS" > /etc/postfix/relay_passwd
postmap /etc/postfix/relay_passwd postmap /etc/postfix/relay_passwd
} }
setup_conf_and_secret postconf -e "myhostname = $MTP_HOST"
postconf -e 'inet_interfaces = all'
if [ ! -z "$MTP_RELAY" -a ! -z "$MTP_PORT" -a ! -z "$MTP_USER" -a ! -z "$MTP_PASS" ]; then
setup_conf_and_secret
else
postconf -e 'mynetworks = 127.0.0.1/32 192.168.0.0/16 172.16.0.0/12 10.0.0.0/8'
fi
service rsyslog start service rsyslog start
service postfix start service postfix start
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment