dovecot_config_version = 2.4.0
dovecot_storage_version = 2.4.0

# Dovecot 2.4.x Konfiguration
# Protokolle (korrigiert zurück zu 'imap')
protocols = imap pop3

import_environment {
  USER_PASSWORD=%{env:USER_PASSWORD|default('password')}
  DOVEADM_PASSWORD=%{env:DOVEADM_PASSWORD|default('supersecret')}
}

# Logging (Block-Syntax)
log_path = /var/log/dovecot.log
info_log_path = /var/log/dovecot-info.log
debug_log_path = /var/log/dovecot-debug.log

# Mail-Location
mail_driver=maildir
mailbox_list_layout=index
mailbox_list_utf8=yes
mail_path=~/mail
mail_home=/var/vmail/%{user | domain }/%{user | username }
mail_utf8_extensions = yes

default_internal_user = vmail
default_login_user = vmail
default_internal_group = vmail

mail_uid = vmail
mail_gid = vmail

# Authentifizierung
# auth_mechanisms = plain login
# auth_allow_cleartext = yes

# Passwd-Datenbank (mit Namen und korrekter Syntax)
# passdb passwd-file {
#   passdb_driver = passwd-file
#   passdb_args = username_format=%u password_hash=plaintext /etc/dovecot/passwd
# }
passdb static {
  password=%{env:USER_PASSWORD}
}

# userdb passwd-file {
#   userdb_driver = passwd-file
#   userdb_args = username_format=%u uid=vmail gid=vmail /etc/dovecot/passwd
# }
ssl = yes
ssl_server_cert_file = /etc/dovecot/ssl/imap.bizmatch.net/fullchain1.pem
ssl_server_key_file = /etc/dovecot/ssl/imap.bizmatch.net/privkey1.pem
# Mail-Berechtigungen (nicht mehr in Service-Blöcken nötig)
# uid/gid jetzt direkt in userdb definiert

# SSL-Einstellungen
# ssl = yes
# ssl_cert = </etc/dovecot/ssl/imap.bizmatch.net/fullchain1.pem
# ssl_key = </etc/dovecot/ssl/imap.bizmatch.net/privkey1.pem

# SNI-Konfiguration (korrigierte Syntax)
# service imap-login {
#   ssl_server_name = imap.haiky.app {
#     ssl_cert = </etc/dovecot/ssl/imap.haiky.app/fullchain1.pem
#     ssl_key = </etc/dovecot/ssl/imap.haiky.app/privkey1.pem
#   }
  
#   ssl_server_name = imap.andreasknuth.de {
#     ssl_cert = </etc/dovecot/ssl/imap.andreasknuth.de/fullchain1.pem
#     ssl_key = </etc/dovecot/ssl/imap.andreasknuth.de/privkey1.pem
#   }
# }