settings: use email.smtp.smtp_relay_enabled

This commit is contained in:
Tagadda 2022-02-14 12:24:43 +00:00
parent eb747cc15e
commit f0bf8dd1fd
3 changed files with 15 additions and 11 deletions

View file

@ -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

View file

@ -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' \

View file

@ -29,6 +29,8 @@ class MyMigration(Migration):
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)