From f0bf8dd1fdfe923d7c39a85b679f728f731b3df4 Mon Sep 17 00:00:00 2001 From: Tagadda <36127788+Tagadda@users.noreply.github.com> Date: Mon, 14 Feb 2022 12:24:43 +0000 Subject: [PATCH] settings: use email.smtp.smtp_relay_enabled --- conf/postfix/main.cf | 4 ++-- hooks/conf_regen/19-postfix | 16 +++++++++------- .../0024_global_settings_to_configpanel.py | 6 ++++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/conf/postfix/main.cf b/conf/postfix/main.cf index 3e53714d0..13b68cafa 100644 --- a/conf/postfix/main.cf +++ b/conf/postfix/main.cf @@ -81,7 +81,7 @@ alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases mydomain = {{ main_domain }} mydestination = localhost -{% if relay_host == "" %} +{% if relay_enabled != "True" %} relayhost = {% else %} relayhost = [{{ relay_host }}]:{{ relay_port }} @@ -198,7 +198,7 @@ smtpd_client_recipient_rate_limit=150 # and after to send spam disable_vrfy_command = yes -{% if relay_user != "" %} +{% if relay_enabled == "True" %} # Relay email through an other smtp account # enable SASL authentication smtp_sasl_auth_enable = yes diff --git a/hooks/conf_regen/19-postfix b/hooks/conf_regen/19-postfix index 177ea23e9..8a767c404 100755 --- a/hooks/conf_regen/19-postfix +++ b/hooks/conf_regen/19-postfix @@ -22,17 +22,19 @@ do_pre_regen() { main_domain=$(cat /etc/yunohost/current_host) # Support different strategy for security configurations - export compatibility="$(yunohost settings get 'security.postfix.compatibility')" + export compatibility="$(yunohost settings get 'security.postfix.postfix_compatibility')" # Add possibility to specify a relay # Could be useful with some isp with no 25 port open or more complex setup export relay_port="" export relay_user="" - export relay_host="$(yunohost settings get 'smtp.relay.host')" - if [ -n "${relay_host}" ]; then - relay_port="$(yunohost settings get 'smtp.relay.port')" - relay_user="$(yunohost settings get 'smtp.relay.user')" - relay_password="$(yunohost settings get 'smtp.relay.password')" + export relay_host="" + export relay_enabled="$(yunohost settings get 'email.smtp.smtp_relay_enabled')" + if [ "${relay_enabled}" == "True" ]; then + relay_host="$(yunohost settings get 'email.smtp.smtp_relay_host')" + relay_port="$(yunohost settings get 'email.smtp.smtp_relay_port')" + relay_user="$(yunohost settings get 'email.smtp.smtp_relay_user')" + relay_password="$(yunohost settings get 'email.smtp.smtp_relay_password')" # Avoid to display "Relay account paswword" to other users touch ${postfix_dir}/sasl_passwd @@ -54,7 +56,7 @@ do_pre_regen() { >"${default_dir}/postsrsd" # adapt it for IPv4-only hosts - ipv6="$(yunohost settings get 'smtp.allow_ipv6')" + ipv6="$(yunohost settings get 'email.smtp.smtp_allow_ipv6')" if [ "$ipv6" == "False" ] || [ ! -f /proc/net/if_inet6 ]; then sed -i \ 's/ \[::ffff:127.0.0.0\]\/104 \[::1\]\/128//g' \ diff --git a/src/migrations/0024_global_settings_to_configpanel.py b/src/migrations/0024_global_settings_to_configpanel.py index 7283f168b..977e1349f 100644 --- a/src/migrations/0024_global_settings_to_configpanel.py +++ b/src/migrations/0024_global_settings_to_configpanel.py @@ -28,7 +28,9 @@ class MyMigration(Migration): raise YunohostError("global_settings_cant_open_settings", reason=e) settings = { k: v['values'] for k,v in old_settings.items() } - + + if settings.get('smtp.relay.host') != "": + settings['email.smtp.smtp_relay_enabled'] == "True" + args = urllib.parse.urlencode(settings) settings_set(args=args) -