1
0
mirror of https://github.com/tomav/docker-mailserver.git synced 2024-06-28 04:01:20 +02:00
docker-mailserver/target/bin/addrelayhost
Paul Adams f28e9843ce Implementation of multi-domain relay hosts (#922, #926)
* Add new configuration for multi-domain relay hosts (#922)
 * Creates new environment variables (replacing existing AWS_SES variables)
 * Optionally allows more advanced setups using config files
* Update relay hosts during change detection (#922)
* Add helper scripts for adding relay hosts and per-domain auth
* Allow the possibility to deliver some mail directly
* adding a domain with no destination will exclude it from the
  relayhost_map and so Postfix will attempt to deliver the mail directly
* tests for setup.sh script
* tests for relay host configuration
* these tests cover the code in `start-mailserver.sh` dealing with both
  the env vars and the configuration files
2018-04-02 10:45:58 +02:00

34 lines
589 B
Bash
Executable File

#! /bin/bash
DATABASE=${DATABASE:-/tmp/docker-mailserver/postfix-relaymap.cf}
DOMAIN="$1"
HOST="$2"
PORT="$3"
usage() {
echo "Usage: addrelayhost <domain> <host> [<port>]"
}
errex() {
echo "$@" 1>&2
exit 1
}
escape() {
echo "${1//./\\.}"
}
[ -z "$DOMAIN" ] && { usage; errex "no domain specified"; }
[ -z "$HOST" ] && { usage; errex "no relay host specified"; }
if [ -z "$PORT" ]; then
PORT=25
fi
if grep -qi "^@$DOMAIN" $DATABASE 2>/dev/null; then
sed -i "s ^@"$DOMAIN".* "@$DOMAIN"\t\t["$HOST"]:"$PORT" " $DATABASE
else
echo -e "@$DOMAIN\t\t[$HOST]:$PORT" >> $DATABASE
fi