Commit cada36b7 by Alin Voinea

Refs #70500 - Update documentation; Fix docker-setup.sh

parent 86615b21
# Postfix Image for SMTP Auth
# Postfix SMTP only with relay support
This image is a CentOS 7 container running postfix pre-configured 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 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 relay is set in `MTP_RELAY` and the port in `MTP_PORT`.
Postfix SMTP only Docker image with SMTP relay support.
## Supported tags and respective Dockerfile links
......@@ -25,40 +18,35 @@ The relay is set in `MTP_RELAY` and the port in `MTP_PORT`.
- [github.com](http://github.com/eea/eea.docker.postfix)
## Usage
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`:
MTP_USER=user
MTP_PASS=password
Basic way to get one instance up and running:
docker run --rm -t -i -e MTP_HOST=mydomain.com --env-file=.secret -v /etc/localtime:/etc/localtime:ro --name=postfix eeacms/postfix
Start postfix (to send emails using postfix within container)
From the application container, running on the same docker host, one can set the SMTP server to the postfix container address.
$ docker run --rm --name=postfix \
-e MTP_HOST=foo.com \
eeacms/postfix
Using the mount directive ```-v /etc/localtime:/etc/localtime:ro``` will make sure that the postfix container will share same timezone as the host, so that the emails have correct date and timestamps.
or start postfix (to send emails by using a remote email server)
## Example usage
$ docker run --rm --name=postfix \
-e MTP_HOST=foo.com \
-e MTP_RELAY=smtp.gmail.com \
-e MTP_USER=foo \
-e MTP_PASS=secret \
eeacms/postfix
From the postfix container ("postfix"):
Start sending emails:
# from an application, python:
$ python
>>> import smtplib, os
>>> s = smtplib.SMTP(os.getenv('HOSTNAME'))
>>> s.sendmail('test@mydomain.com', ['user@example.com'], 'test')
From another application container ("app"):
docker run --rm -it -v /etc/localtime:/etc/localtime:ro --name=app --link=postfix:postfixcontainer app_image
# from an application, python:
$ python
>>> import smtplib
>>> s = smtplib.SMTP('postfixcontainer')
>>> s.sendmail('test@mydomain.com', ['user@example.com'], 'test')
$ docker run -it --rm --link=postfix alpine sh
$ telnet postfix 25
HELO foo.com
MAIL FROM: bar@foo.com
RCPT TO: foo@bar.com
DATA
subject: Test
Testing 1, 2, 3
.
quit
## Supported environment variables
......@@ -83,7 +71,6 @@ General Public License as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later
version.
## Funding
[European Environment Agency (EU)](http://eea.europa.eu)
......@@ -9,6 +9,6 @@ postfix.service: {
}
console.logging: {
selector: "*.warn",
selector: "*.info",
stdout: true
}
......@@ -16,25 +16,25 @@ function setup_conf_and_secret {
}
if [ -z "$MTP_INTERFACES" ]; then
postconf -e 'inet_interfaces = all'
postconf -e "inet_interfaces = all"
else
postconf -e 'inet_interfaces = $MTP_INTERFACES'
postconf -e "inet_interfaces = $MTP_INTERFACES"
fi
if [ ! -z "$MTP_HOST" ]; then
postconf -e 'myhostname = $MTP_HOST'
postconf -e "myhostname = $MTP_HOST"
fi
if [ ! -z "$MTP_DESTINATION" ]; then
postconf -e 'mydestination = $MTP_DESTINATION'
postconf -e "mydestination = $MTP_DESTINATION"
fi
if [ ! -z "$MTP_BANNER" ]; then
postconf -e 'smtpd_banner = $MTP_BANNER'
postconf -e "smtpd_banner = $MTP_BANNER"
fi
if [ ! -z "$MTP_RELAY_DOMAINS" ]; then
postconf -e 'relay_domains = $MTP_RELAY_DOMAINS'
postconf -e "relay_domains = $MTP_RELAY_DOMAINS"
fi
if [ ! -z "$MTP_RELAY" -a ! -z "$MTP_PORT" -a ! -z "$MTP_USER" -a ! -z "$MTP_PASS" ]; then
......
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