From fb4693be3959d6306eb4a23c62b13992b2c547d2 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 20 Jun 2023 17:59:09 +0200 Subject: [PATCH] apps: be able to customize the user-part and domain-part of email when using allow_email on system user --- src/app.py | 4 +++- src/utils/resources.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app.py b/src/app.py index 88d79e750..a7d25cfa6 100644 --- a/src/app.py +++ b/src/app.py @@ -3173,7 +3173,9 @@ def regen_mail_app_user_config_for_dovecot_and_postfix(only=None): hashed_password = _hash_user_password(settings["mail_pwd"]) dovecot_passwd.append(f"{app}:{hashed_password}::::::allow_nets=127.0.0.1/24") if postfix: - postfix_map.append(f"{app}@{settings['domain']} {app}") + mail_user = settings.get("mail_user", app) + mail_domain = settings.get("mail_domain", settings["domain"]) + postfix_map.append(f"{mail_user}@{mail_domain} {app}") if dovecot: app_senders_passwd = "/etc/dovecot/app-senders-passwd" diff --git a/src/utils/resources.py b/src/utils/resources.py index 4e1907ab4..925ce6ee8 100644 --- a/src/utils/resources.py +++ b/src/utils/resources.py @@ -451,7 +451,7 @@ class SystemuserAppResource(AppResource): ##### Properties: - `allow_ssh`: (default: False) Adds the user to the ssh.app group, allowing SSH connection via this user - `allow_sftp`: (default: False) Adds the user to the sftp.app group, allowing SFTP connection via this user - - `allow_email`: (default: False) Enable authentication on the mail stack for the system user and send mail using `__APP__@__DOMAIN__`. A `mail_pwd` setting is automatically defined (similar to `db_pwd` for databases). You can then configure the app to use `__APP__` and `__MAIL_PWD__` as SMTP credentials (with host 127.0.0.1) + - `allow_email`: (default: False) Enable authentication on the mail stack for the system user and send mail using `__APP__@__DOMAIN__`. A `mail_pwd` setting is automatically defined (similar to `db_pwd` for databases). You can then configure the app to use `__APP__` and `__MAIL_PWD__` as SMTP credentials (with host 127.0.0.1). You can also tweak the user-part of the domain-part of the email used by manually defining a custom setting `mail_user` or `mail_domain` - `home`: (default: `/var/www/__APP__`) Defines the home property for this user. NB: unfortunately you can't simply use `__INSTALL_DIR__` or `__DATA_DIR__` for now ##### Provision/Update: