diff --git a/scripts/40-postfix.sh b/scripts/40-postfix.sh index 2566000..8f530bc 100644 --- a/scripts/40-postfix.sh +++ b/scripts/40-postfix.sh @@ -85,7 +85,11 @@ dbname = ${DB_NAME} query = SELECT 1 FROM mail_users u JOIN domains d ON d.id = u.domain_id - WHERE u.email = '%s' AND u.is_active = 1 AND d.is_active = 1 + WHERE u.email = '%s' + AND u.is_active = 1 + AND u.can_login = 1 + AND u.password_hash IS NOT NULL + AND d.is_active = 1 LIMIT 1; CONF chown root:postfix /etc/postfix/sql/mysql-virtual-mailbox-maps.cf @@ -97,11 +101,18 @@ hosts = 127.0.0.1 user = ${DB_USER} password = ${DB_PASS} dbname = ${DB_NAME} -query = SELECT destination - FROM mail_aliases a - JOIN domains d ON d.id = a.domain_id - WHERE a.source = '%s' AND a.is_active = 1 AND d.is_active = 1 - LIMIT 1; + +query = SELECT COALESCE(mu.email, r.email) AS destination + FROM mail_aliases a + JOIN domains d ON d.id = a.domain_id + JOIN mail_alias_recipients r ON r.alias_id = a.id + LEFT JOIN mail_users mu ON mu.id = r.mail_user_id + WHERE d.domain = SUBSTRING_INDEX('%s','@',-1) + AND a.local = SUBSTRING_INDEX('%s','@', 1) + AND a.is_active = 1 + AND d.is_active = 1 + AND (mu.email IS NOT NULL OR r.email IS NOT NULL) +ORDER BY r.position ASC; CONF chown root:postfix /etc/postfix/sql/mysql-virtual-alias-maps.cf chmod 640 /etc/postfix/sql/mysql-virtual-alias-maps.cf diff --git a/scripts/50-dovecot.sh b/scripts/50-dovecot.sh index cfbac68..f4a07ff 100644 --- a/scripts/50-dovecot.sh +++ b/scripts/50-dovecot.sh @@ -55,6 +55,36 @@ first_valid_uid = ${VMAIL_UID} last_valid_uid = ${VMAIL_UID} CONF +# Standard-Mailboxen automatisch erstellen/abonnieren +cat > /etc/dovecot/conf.d/15-mailboxes.conf <<'CONF' +namespace inbox { + inbox = yes + + mailbox Drafts { + special_use = \Drafts + auto = subscribe + } + mailbox Junk { + special_use = \Junk + auto = subscribe + } + mailbox Trash { + special_use = \Trash + auto = subscribe + } + mailbox Sent { + special_use = \Sent + auto = subscribe + } + + # optional: Archive + mailbox Archive { + special_use = \Archive + auto = create + } +} +CONF + # Auth cat > /etc/dovecot/conf.d/10-auth.conf <<'CONF' disable_plaintext_auth = yes @@ -67,9 +97,14 @@ cat > /etc/dovecot/dovecot-sql.conf.ext < /etc/dovecot/conf.d/10-master.conf <<'CONF' service lmtp { unix_listener /var/spool/postfix/private/dovecot-lmtp {