/etc/dovecot/local.conf

# listen both ipv4 and ipv6
listen = *, [::]

# imap c'est mieux que pop
protocols = imap 

# securisation via ssl
ssl = yes
ssl_cert = </etc/ssl/chezmoi.tld-fullchain.pem
ssl_key = </etc/ssl/private/chezmoi.tld.key
# pas de plaintext
disable_plaintext_auth = yes

# Modification des permissions pour limiter la lecture du fichier des mots de passe
# au groupe _maildaemons
service auth {
  user = $default_internal_user
  group = _maildaemons
}

# Identification par fichier
passdb {
    args = scheme=blf-crypt /etc/mail/passwd
    driver = passwd-file
}

userdb {
    driver = static
    args = uid=_vmail gid=_vmail home=/mnt/bigstorage/_vmail/%d/%n/ 
}

# Plugins
mail_plugins = $mail_plugins quota zlib
# Activation des plugins : 
# - Support des quotas
# - zlib limite la bande passante par compression
# - sieve pour filtres personalises. **Il faut le paquet dovecot-pigeonhole**
protocol imap {
    mail_plugins = $mail_plugins imap_quota imap_zlib imap_sieve
}


# Configuration des plugins
plugin {
        #plugin quota
  quota = maildir:User quota
  quota_rule = *:storage=1G
  quota_rule2 = Trash:storage=+100M
  quota_grace = 50%%
  quota_status_success = DUNNO
  quota_status_nouser = DUNNO
  quota_status_overquota = "552 5.2.2 Mailbox is full"

  # Compression maxi
  zlib_save_level = 9 # 1..9; default is 6
  zlib_save = gz # or bz2, xz or lz4

        # Sieve
        # -----
  sieve_plugins = sieve_imapsieve sieve_extprograms
        
        # Script sieve execute par defaut (antispam)
        sieve_default = /usr/local/lib/dovecot/sieve/default.sieve

  # Scripte pour enregistrer comme spam quand mails deplace dans dossier Junk
  imapsieve_mailbox1_name = Junk
  imapsieve_mailbox1_causes = COPY
  imapsieve_mailbox1_before = file:/usr/local/lib/dovecot/sieve/report-spam.sieve

  # Enregistrer mail comme pas-spam si retire du dossier Junk
  imapsieve_mailbox2_name = *
  imapsieve_mailbox2_from = Junk
  imapsieve_mailbox2_causes = COPY
  imapsieve_mailbox2_before = file:/usr/local/lib/dovecot/sieve/report-ham.sieve

  sieve_pipe_bin_dir = /usr/local/lib/dovecot/sieve

  sieve_global_extensions = +vnd.dovecot.pipe +vnd.dovecot.environment
}