diff --git a/2.Common_services/1.Postfix/0_setup.py b/2.Common_services/1.Postfix/0_setup.py index c7fff0731da2159f2257de723e694e3837682698..aa4d40fc8ff9dc9d3651ca4872b42155dd526a8a 100644 --- a/2.Common_services/1.Postfix/0_setup.py +++ b/2.Common_services/1.Postfix/0_setup.py @@ -12,15 +12,21 @@ def setup(interactive=True): else: raise Exception('Failed to get hostname.') # Install and configure postfix + server = utils.get_conf('EMAIL_SMTP_SERVER', '') + if not server: + # with relayless cases emails are not always delivered to google mailing lists unless mailname is ubicast.eu and DNS spf records are set + mailname = 'ubicast.eu' + else: + mailname = utils.get_conf('MS_SERVER_NAME', hostname) dir_path = utils.get_dir(__file__) cmds = [ 'DEBIAN_FRONTEND=noninteractive apt-get install -y postfix mailutils', 'echo "Replacing /etc/postfix/main.cf"', dict(line='write', template='%s/main.cf' % dir_path, target='/etc/postfix/main.cf', params=( ('{{ hostname }}', hostname), - ('{{ smtp }}', utils.get_conf('EMAIL_SMTP_SERVER', '')), + ('{{ smtp }}', server), )), - 'echo "%s" > /etc/mailname' % hostname, + 'echo "%s" > /etc/mailname' % mailname, 'rgrep root /etc/aliases || echo "root: sysadmin@ubicast.eu" >> /etc/aliases', 'service postfix restart', 'newaliases',