## Dovecot - Auth SQL via PostgreSQL
## Base: esymail | Table: mailbox

protocols = imap pop3

listen = *

# Logging
log_path = /var/log/dovecot/dovecot.log
info_log_path = /var/log/dovecot/dovecot-info.log
auth_verbose = yes
auth_debug = no

# Mail location (un dossier par utilisateur)
mail_location = maildir:/var/mail/vhosts/%d/%n

# Namespace INBOX
namespace inbox {
  inbox = yes
  separator = /
}

# Auth via SQL
passdb {
  driver = sql
  args = /etc/dovecot/dovecot-sql.conf
}

userdb {
  driver = sql
  args = /etc/dovecot/dovecot-sql.conf
}

# UID/GID pour vmail
mail_uid = 1000
mail_gid = 1000
first_valid_uid = 1000
last_valid_uid = 1000

# SSL (desactive en dev, TLS via reverse proxy en prod)
ssl = no

# Service IMAP
service imap-login {
  inet_listener imap {
    port = 143
  }
}

# Service POP3
service pop3-login {
  inet_listener pop3 {
    port = 110
  }
}

# Auth TCP pour Postfix SASL (entre containers Docker)
service auth {
  inet_listener {
    port = 12345
  }
}
