fix(mailserver): Fix mydestination conflict with virtual domains

mydestination included $mydomain which caused "User unknown in local
recipient table" errors because Postfix treated the domain as local
instead of virtual.

Changes:
- Remove $mydomain from mydestination in setup.sh
- Update fix-postfix command to also fix this issue
- Ensure vdomains file is properly created

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
CyberMind-FR 2026-02-05 12:36:28 +01:00
parent ae26317815
commit b7f3eb9613
2 changed files with 16 additions and 6 deletions

View File

@ -77,7 +77,8 @@ echo "disable_plaintext_auth = no" >> /etc/dovecot/dovecot.conf
# Configure postfix
postconf -e 'myhostname = MAIL_HOSTNAME'
postconf -e 'mydomain = MAIL_DOMAIN'
postconf -e 'mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain'
# Don't include $mydomain in mydestination - it conflicts with virtual_mailbox_domains
postconf -e 'mydestination = $myhostname, localhost.$mydomain, localhost'
postconf -e 'inet_interfaces = all'
postconf -e 'home_mailbox = Maildir/'
postconf -e 'smtpd_sasl_type = dovecot'

View File

@ -291,13 +291,22 @@ cmd_mesh() {
cmd_fix_postfix() {
local container=$(uci_get main.container)
container="${container:-mailserver}"
local domain=$(uci_get main.domain)
log "Fixing Postfix configuration..."
# Fix LMDB maps (Alpine doesn't support hash maps)
lxc-attach -n "$container" -- sh -c '
postconf -e "virtual_mailbox_maps = lmdb:/etc/postfix/vmailbox"
postconf -e "virtual_alias_maps = lmdb:/etc/postfix/virtual"
lxc-attach -n "$container" -- sh -c "
# Use LMDB instead of hash (Alpine Postfix)
postconf -e 'virtual_mailbox_maps = lmdb:/etc/postfix/vmailbox'
postconf -e 'virtual_alias_maps = lmdb:/etc/postfix/virtual'
postconf -e 'virtual_mailbox_domains = /etc/postfix/vdomains'
# Don't include domain in mydestination (conflicts with virtual)
postconf -e 'mydestination = \\\$myhostname, localhost.\\\$mydomain, localhost'
# Ensure vdomains file exists
echo '$domain' > /etc/postfix/vdomains
# Regenerate LMDB databases
[ -f /etc/postfix/vmailbox ] && postmap lmdb:/etc/postfix/vmailbox
@ -309,10 +318,10 @@ cmd_fix_postfix() {
# Reload Postfix
postfix reload
'
"
log "Postfix configuration fixed"
log "If you still see 'Temporary lookup failure', restart the container: mailctl restart"
log "If you still see errors, restart the container: mailctl restart"
}
# ============================================================================