diff --git a/.claude/WIP.md b/.claude/WIP.md index ae1619a7..4113a8c0 100644 --- a/.claude/WIP.md +++ b/.claude/WIP.md @@ -63,6 +63,13 @@ _Last updated: 2026-02-06_ - Fix: Changed to use socat proxy at `172.17.0.1:10143` (plaintext, internal) - Updated `mailctl webmail configure` to use proxy instead of direct SSL +- **Mail Send 451 "Temporary lookup failure"** — RESOLVED (2026-02-06) + - Root cause: Alpine Postfix uses LMDB, not BerkeleyDB hash maps + - `virtual_alias_maps = hash:/etc/postfix/virtual` was invalid + - Postfix chroot `/var/spool/postfix/etc/resolv.conf` was missing + - Fix: Changed setup.sh to use `lmdb:` prefix and copy resolv.conf to chroot + - Added `mailctl fix-postfix` command to repair existing installations + ### Just Completed - **Unified Backup Manager** — DONE (2026-02-05) diff --git a/package/secubox/secubox-app-mailserver/files/usr/lib/mailserver/container.sh b/package/secubox/secubox-app-mailserver/files/usr/lib/mailserver/container.sh index 9505200d..4a915c99 100644 --- a/package/secubox/secubox-app-mailserver/files/usr/lib/mailserver/container.sh +++ b/package/secubox/secubox-app-mailserver/files/usr/lib/mailserver/container.sh @@ -88,9 +88,13 @@ postconf -e 'smtpd_tls_key_file = /etc/ssl/mail/privkey.pem' postconf -e 'smtpd_tls_security_level = may' postconf -e 'smtp_tls_security_level = may' postconf -e 'virtual_mailbox_domains = /etc/postfix/vdomains' -postconf -e 'virtual_mailbox_maps = hash:/etc/postfix/vmailbox' -postconf -e 'virtual_alias_maps = hash:/etc/postfix/valias' +# Alpine Postfix uses LMDB, not BerkeleyDB hash +postconf -e 'virtual_mailbox_maps = lmdb:/etc/postfix/vmailbox' +postconf -e 'virtual_alias_maps = lmdb:/etc/postfix/valias' postconf -e 'virtual_mailbox_base = /var/mail' +# Copy resolv.conf to Postfix chroot for DNS lookups +mkdir -p /var/spool/postfix/etc +cp /etc/resolv.conf /var/spool/postfix/etc/ postconf -e 'virtual_uid_maps = static:1000' postconf -e 'virtual_gid_maps = static:1000' # Create vmail user diff --git a/package/secubox/secubox-app-mailserver/files/usr/sbin/mailctl b/package/secubox/secubox-app-mailserver/files/usr/sbin/mailctl index 200f301a..813e6a27 100644 --- a/package/secubox/secubox-app-mailserver/files/usr/sbin/mailctl +++ b/package/secubox/secubox-app-mailserver/files/usr/sbin/mailctl @@ -284,6 +284,37 @@ cmd_mesh() { esac } +# ============================================================================ +# Fix / Repair +# ============================================================================ + +cmd_fix_postfix() { + local container=$(uci_get main.container) + container="${container:-mailserver}" + + 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" + + # Regenerate LMDB databases + [ -f /etc/postfix/vmailbox ] && postmap lmdb:/etc/postfix/vmailbox + [ -f /etc/postfix/virtual ] && postmap lmdb:/etc/postfix/virtual + + # Fix Postfix chroot DNS resolution + mkdir -p /var/spool/postfix/etc + cp /etc/resolv.conf /var/spool/postfix/etc/ + + # Reload Postfix + postfix reload + ' + + log "Postfix configuration fixed" + log "If you still see 'Temporary lookup failure', restart the container: mailctl restart" +} + # ============================================================================ # Logs & Diagnostics # ============================================================================ @@ -509,6 +540,7 @@ Diagnostics: logs [lines] View mail logs test Send test email ssl-status Show SSL cert info + fix-postfix Fix LMDB maps and DNS resolution Examples: mailctl install @@ -540,6 +572,7 @@ case "${1:-}" in logs) shift; cmd_logs "$@" ;; test) shift; cmd_test "$@" ;; report) shift; cmd_report "$@" ;; + fix-postfix) shift; cmd_fix_postfix "$@" ;; help|--help|-h|'') show_help ;; *) error "Unknown command: $1"; show_help >&2; exit 1 ;; esac