mirror of
https://github.com/docker-mailserver/docker-mailserver
synced 2024-12-18 14:04:17 +01:00
59 lines
1.9 KiB
Bash
Executable File
59 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# shellcheck source=../scripts/helpers/index.sh
|
|
source /usr/local/bin/helpers/index.sh
|
|
|
|
function _main() {
|
|
_require_n_parameters_or_print_usage 1 "${@}"
|
|
|
|
local DOMAIN="${1}"
|
|
|
|
_exclude_domain_from_relayhosts
|
|
}
|
|
|
|
function __usage() {
|
|
printf '%s' "${PURPLE}excluderelayhost${RED}(${YELLOW}8${RED})
|
|
|
|
${ORANGE}USAGE${RESET}
|
|
./setup.sh relay exclude-domain <SENDER DOMAIN>
|
|
|
|
${ORANGE}OPTIONS${RESET}
|
|
${BLUE}Generic Program Information${RESET}
|
|
help Print the usage information.
|
|
|
|
${ORANGE}DESCRIPTION${RESET}
|
|
When a default relay-host is configured (via ENV), the default behaviour
|
|
is to relay all your mail accounts outgoing mail through that service.
|
|
|
|
This command allows to opt-out from that default behaviour by excluding
|
|
all mail accounts belonging to a hosted domain you specify.
|
|
|
|
${ORANGE}EXAMPLES${RESET}
|
|
${LWHITE}./setup.sh relay exclude-domain example.com${RESET}
|
|
Any mail submitted from your '@example.com' accounts will be sent
|
|
without relaying through a default relay-host (if one was configured).
|
|
|
|
${ORANGE}EXIT STATUS${RESET}
|
|
Exit status is 0 if command was successful. If wrong arguments are provided
|
|
or arguments contain errors, the script will exit early with exit status 1.
|
|
|
|
"
|
|
}
|
|
|
|
# Config is for sender dependent relay-host mapping,
|
|
# excludes appending a sender from the real generated mapping in `helpers/relay.sh`.
|
|
function _exclude_domain_from_relayhosts() {
|
|
local SENDER="@${DOMAIN}"
|
|
local DATABASE_RELAY='/tmp/docker-mailserver/postfix-relaymap.cf'
|
|
|
|
# NOTE: No third arg is required.
|
|
# This won't cause any problems, a 'space' will be added with the key.
|
|
# That helps ensure repeat DB edits for the entry match correctly.
|
|
#
|
|
# `helpers/relay.sh` is also fine with this, and will eventually drop
|
|
# the need for this command entirely once that helper is refactored.
|
|
_db_entry_add_or_replace "${DATABASE_RELAY}" "${SENDER}"
|
|
}
|
|
|
|
_main "${@}"
|