fix(mailserver): Align Postfix/Dovecot mail paths for Roundcube visibility

- Change mount point from var/mail to home/vmail for proper Dovecot integration
- Update virtual_mailbox_base from /var/mail to /home/vmail
- Create Maildir/{cur,new,tmp} structure matching Dovecot's mail_location
- Fix vmailbox entries to include Maildir/ suffix
- Update vmail user home directory to /home/vmail

This resolves the issue where emails delivered by Postfix were not visible
in Roundcube because Dovecot was looking in ~/Maildir/ subdirectory.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
CyberMind-FR 2026-02-06 12:15:47 +01:00
parent fb28b17c3f
commit f70d5cce79
3 changed files with 13 additions and 11 deletions

View File

@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=secubox-app-mailserver
PKG_VERSION:=1.0.0
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_MAINTAINER:=SecuBox Team
PKG_LICENSE:=MIT

View File

@ -30,7 +30,7 @@ lxc.net.0.ipv4.address = auto
lxc.cgroup2.memory.max = 536870912
lxc.seccomp.profile =
lxc.mount.entry = $data_path/mail var/mail none bind,create=dir 0 0
lxc.mount.entry = $data_path/mail home/vmail none bind,create=dir 0 0
lxc.mount.entry = $data_path/config etc/postfix none bind,create=dir 0 0
lxc.mount.entry = $data_path/ssl etc/ssl/mail none bind,create=dir 0 0
@ -42,7 +42,7 @@ EOF
echo "Bootstrapping Alpine rootfs..."
local rootfs="$LXC_DIR/$name/rootfs"
mkdir -p "$rootfs"/{dev,proc,sys,tmp,var/log,var/mail,etc/{postfix,dovecot,ssl/mail}}
mkdir -p "$rootfs"/{dev,proc,sys,tmp,var/log,home/vmail,etc/{postfix,dovecot,ssl/mail}}
# Download and extract Alpine minirootfs
local arch="aarch64"
@ -92,15 +92,15 @@ postconf -e 'virtual_mailbox_domains = /etc/postfix/vdomains'
# 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'
postconf -e 'virtual_mailbox_base = /home/vmail'
# 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
# Create vmail user with home at /home/vmail
addgroup -g 1000 vmail
adduser -D -u 1000 -G vmail -h /var/mail vmail
adduser -D -u 1000 -G vmail -h /home/vmail vmail
# Enable services
rc-update add postfix default
rc-update add dovecot default

View File

@ -26,15 +26,17 @@ user_add() {
# Validate
echo "$email" | grep -qE '^[^@]+@[^@]+\.[^@]+$' || { echo "Invalid email format"; return 1; }
# Create mailbox directory
local maildir="$data_path/mail/$domain/$user"
# Create mailbox directory with Maildir structure
# Dovecot expects ~/Maildir/ so we create $domain/$user/Maildir/
local maildir="$data_path/mail/$domain/$user/Maildir"
mkdir -p "$maildir"/{cur,new,tmp}
chown -R 1000:1000 "$maildir"
chown -R 1000:1000 "$data_path/mail/$domain/$user"
# Add to virtual mailbox map
# Add to virtual mailbox map (path relative to virtual_mailbox_base)
# Must end with Maildir/ to match Dovecot's mail_location = maildir:~/Maildir
local vmailbox="$data_path/config/vmailbox"
touch "$vmailbox"
grep -q "^$email" "$vmailbox" || echo "$email $domain/$user/" >> "$vmailbox"
grep -q "^$email" "$vmailbox" || echo "$email $domain/$user/Maildir/" >> "$vmailbox"
# Generate password hash
if [ -z "$password" ]; then