From a729c78379e738d00d83b5809df1e516144c5851 Mon Sep 17 00:00:00 2001 From: Josue-T Date: Sat, 23 Dec 2023 19:34:22 +0100 Subject: [PATCH] apps: add mailbox/IMAP support for apps that declared a system user with mail enabled (#1745) * Add missing account registration for apps in postfix * Also set email on dovecot DB * fix undefined var * Fix missing username format config in dovecot --- conf/dovecot/dovecot.conf | 2 +- conf/postfix/main.cf | 4 ++-- src/app.py | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/conf/dovecot/dovecot.conf b/conf/dovecot/dovecot.conf index 1bd5ad5e3..c014a4d23 100644 --- a/conf/dovecot/dovecot.conf +++ b/conf/dovecot/dovecot.conf @@ -57,7 +57,7 @@ userdb { userdb { driver = passwd-file - args = /etc/dovecot/app-senders-passwd + args = username_format=%n /etc/dovecot/app-senders-passwd } protocol imap { diff --git a/conf/postfix/main.cf b/conf/postfix/main.cf index e30ca0874..2867a04c2 100644 --- a/conf/postfix/main.cf +++ b/conf/postfix/main.cf @@ -93,14 +93,14 @@ recipient_delimiter = + inet_interfaces = all #### Fit to the maximum message size to 25mb, more than allowed by GMail or Yahoo #### -# /!\ This size is the size of the attachment in base64. +# /!\ This size is the size of the attachment in base64. # BASE64_SIZE_IN_BYTE = ORIGINAL_SIZE_IN_MEGABYTE * 1,37 *1024*1024 + 980 # See https://serverfault.com/questions/346895/postfix-mail-size-counting message_size_limit = 35914708 # Virtual Domains Control virtual_mailbox_domains = ldap:/etc/postfix/ldap-domains.cf -virtual_mailbox_maps = ldap:/etc/postfix/ldap-accounts.cf +virtual_mailbox_maps = ldap:/etc/postfix/ldap-accounts.cf,hash:/etc/postfix/app_senders_login_maps virtual_mailbox_base = virtual_alias_maps = ldap:/etc/postfix/ldap-aliases.cf,ldap:/etc/postfix/ldap-groups.cf virtual_alias_domains = diff --git a/src/app.py b/src/app.py index ad20b3552..15e266a6d 100644 --- a/src/app.py +++ b/src/app.py @@ -3267,14 +3267,15 @@ def regen_mail_app_user_config_for_dovecot_and_postfix(only=None): if "domain" not in settings or "mail_pwd" not in settings: continue + mail_user = settings.get("mail_user", app) + mail_domain = settings.get("mail_domain", settings["domain"]) + if dovecot: hashed_password = _hash_user_password(settings["mail_pwd"]) dovecot_passwd.append( - f"{app}:{hashed_password}::::::allow_nets=::1,127.0.0.1/24,local" + f"{app}:{hashed_password}::::::allow_nets=::1,127.0.0.1/24,local,mail={mail_user}@{mail_domain}" ) if postfix: - 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: