mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
Support for setting relayhost in main.cf (#1104)
* Added DEFAULT_RELAY_HOST setting * If set this value will be used as the relayhost in /etc/postfix/maincf causing all mail to be delivered using this relay host * Test for default relay host setting
This commit is contained in:
parent
1302ccfe7e
commit
a3724fa91d
10
.env.dist
10
.env.dist
|
@ -305,6 +305,16 @@ SRS_EXCLUDE_DOMAINS=
|
||||||
# rotate and expire keys
|
# rotate and expire keys
|
||||||
SRS_SECRET=
|
SRS_SECRET=
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------------------------------------------------------
|
||||||
|
# ---------------- Default relay host section ---------------------------------------------------------------------------------
|
||||||
|
# -----------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Setup relaying all mail through a default relay host
|
||||||
|
#
|
||||||
|
# empty => don't configure default relay host
|
||||||
|
# default host and optional port to relay all mail through
|
||||||
|
DEFAULT_RELAY_HOST=
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------------------------------------
|
||||||
# ---------------- Multi-domain relay section ---------------------------------------------------------------------------------
|
# ---------------- Multi-domain relay section ---------------------------------------------------------------------------------
|
||||||
# -----------------------------------------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
12
Makefile
12
Makefile
|
@ -244,6 +244,15 @@ run:
|
||||||
-e DMS_DEBUG=0 \
|
-e DMS_DEBUG=0 \
|
||||||
-h mail.my-domain.com -t $(NAME)
|
-h mail.my-domain.com -t $(NAME)
|
||||||
sleep 15
|
sleep 15
|
||||||
|
docker run -d --name mail_with_default_relay \
|
||||||
|
-v "`pwd`/test/config/relay-hosts":/tmp/docker-mailserver \
|
||||||
|
-v "`pwd`/test":/tmp/docker-mailserver-test \
|
||||||
|
-e DEFAULT_RELAY_HOST=default.relay.host.invalid:25 \
|
||||||
|
--cap-add=SYS_PTRACE \
|
||||||
|
-e PERMIT_DOCKER=host \
|
||||||
|
-e DMS_DEBUG=0 \
|
||||||
|
-h mail.my-domain.com -t $(NAME)
|
||||||
|
sleep 15
|
||||||
|
|
||||||
generate-accounts-after-run:
|
generate-accounts-after-run:
|
||||||
docker run --rm -e MAIL_USER=added@localhost.localdomain -e MAIL_PASS=mypassword -t $(NAME) /bin/sh -c 'echo "$$MAIL_USER|$$(doveadm pw -s SHA512-CRYPT -u $$MAIL_USER -p $$MAIL_PASS)"' >> test/config/postfix-accounts.cf
|
docker run --rm -e MAIL_USER=added@localhost.localdomain -e MAIL_PASS=mypassword -t $(NAME) /bin/sh -c 'echo "$$MAIL_USER|$$(doveadm pw -s SHA512-CRYPT -u $$MAIL_USER -p $$MAIL_PASS)"' >> test/config/postfix-accounts.cf
|
||||||
|
@ -309,7 +318,8 @@ clean:
|
||||||
mail_override_hostname \
|
mail_override_hostname \
|
||||||
mail_domainname \
|
mail_domainname \
|
||||||
mail_srs_domainname \
|
mail_srs_domainname \
|
||||||
mail_with_relays
|
mail_with_relays \
|
||||||
|
mail_with_default_relay
|
||||||
|
|
||||||
@if [ -d config.bak ]; then\
|
@if [ -d config.bak ]; then\
|
||||||
rm -rf config ;\
|
rm -rf config ;\
|
||||||
|
|
|
@ -586,6 +586,13 @@ Note: This postgrey setting needs `ENABLE_POSTGREY=1`
|
||||||
- **empty** => Derived from OVERRIDE_HOSTNAME, DOMAINNAME, or the container's hostname
|
- **empty** => Derived from OVERRIDE_HOSTNAME, DOMAINNAME, or the container's hostname
|
||||||
- Set this if auto-detection fails, isn't what you want, or you wish to have a separate container handle DSNs
|
- Set this if auto-detection fails, isn't what you want, or you wish to have a separate container handle DSNs
|
||||||
|
|
||||||
|
## Default Relay Host
|
||||||
|
|
||||||
|
#### DEFAULT_RELAY_HOST
|
||||||
|
|
||||||
|
- **empty** => don't set default relayhost setting in main.cf
|
||||||
|
- default host and port to relay all mail through
|
||||||
|
|
||||||
## Multi-domain Relay Hosts
|
## Multi-domain Relay Hosts
|
||||||
|
|
||||||
#### RELAY_HOST
|
#### RELAY_HOST
|
||||||
|
|
|
@ -77,6 +77,7 @@ services:
|
||||||
- SASL_PASSWD=${SASL_PASSWD}
|
- SASL_PASSWD=${SASL_PASSWD}
|
||||||
- SRS_EXCLUDE_DOMAINS=${SRS_EXCLUDE_DOMAINS}
|
- SRS_EXCLUDE_DOMAINS=${SRS_EXCLUDE_DOMAINS}
|
||||||
- SRS_SECRET=${SRS_SECRET}
|
- SRS_SECRET=${SRS_SECRET}
|
||||||
|
- DEFAULT_RELAY_HOST=${DEFAULT_RELAY_HOST}
|
||||||
- RELAY_HOST=${RELAY_HOST}
|
- RELAY_HOST=${RELAY_HOST}
|
||||||
- RELAY_PORT=${RELAY_PORT}
|
- RELAY_PORT=${RELAY_PORT}
|
||||||
- RELAY_USER=${RELAY_USER}
|
- RELAY_USER=${RELAY_USER}
|
||||||
|
|
|
@ -145,6 +145,10 @@ function register_functions() {
|
||||||
_register_setup_function "_setup_postfix_relay_hosts"
|
_register_setup_function "_setup_postfix_relay_hosts"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ! -z "$DEFAULT_RELAY_HOST" ]; then
|
||||||
|
_register_setup_function "_setup_postfix_default_relay_host"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -z "$RELAY_HOST" ]; then
|
if [ ! -z "$RELAY_HOST" ]; then
|
||||||
_register_setup_function "_setup_postfix_relay_hosts"
|
_register_setup_function "_setup_postfix_relay_hosts"
|
||||||
fi
|
fi
|
||||||
|
@ -1066,6 +1070,13 @@ function _setup_postfix_sasl_password() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _setup_postfix_default_relay_host() {
|
||||||
|
notify 'task' 'Applying default relay host to Postfix'
|
||||||
|
|
||||||
|
notify 'inf' "Applying default relay host $DEFAULT_RELAY_HOST to /etc/postfix/main.cf"
|
||||||
|
postconf -e "relayhost = $DEFAULT_RELAY_HOST"
|
||||||
|
}
|
||||||
|
|
||||||
function _setup_postfix_relay_hosts() {
|
function _setup_postfix_relay_hosts() {
|
||||||
notify 'task' 'Setting up Postfix Relay Hosts'
|
notify 'task' 'Setting up Postfix Relay Hosts'
|
||||||
# copy old AWS_SES variables to new variables
|
# copy old AWS_SES variables to new variables
|
||||||
|
|
|
@ -1748,6 +1748,15 @@ load 'test_helper/bats-assert/load'
|
||||||
assert_success
|
assert_success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# default relay host
|
||||||
|
#
|
||||||
|
|
||||||
|
@test "checking default relay host: default relay host is added to main.cf" {
|
||||||
|
run docker exec mail_with_default_relay /bin/sh -c 'grep -e "^relayhost = default.relay.host.invalid:25" /etc/postfix/main.cf | wc -l | grep 1'
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# relay hosts
|
# relay hosts
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in a new issue