====== Dovecot Installation & Konfiguration ======
===== Quelle =====
  * http://www.binarytides.com/install-postfix-dovecot-debian/
  * https://sys4.de/en/blog/2013/03/25/outlook-2013-special-use-mit-dovecot/
==== Setup ====
apt install -t jessie-backports dovecot-core dovecot-imapd dovecot-lmtpd -y
cp -arf /etc/dovecot/conf.d/ /etc/dovecot/conf.d.BAK
cd /etc/dovecot/conf.d
mkdir -p /var/mail/vhosts/meinekleinefarm.net
mkdir -p /var/mail/vhosts/mgs-ullrich.de
groupadd -g 5000 vmail
useradd -r -g vmail -u 5000 vmail -d /var/mail/vhosts -c "Dovecot virtual mail user"
chown -R vmail:vmail /var/mail/vhosts/
==== 10-mail.conf ====
nano 10-mail.conf
  * 
mail_location = maildir:/var/mail/vhosts/%d/%n
==== 10-master.conf ====
nano 10-master.conf
  * 
service imap-login {
  inet_listener imap {
    #port = 143
  }
  inet_listener imaps {
    port = 993
    ssl = yes
  }
  
service lmtp {
  unix_listener /var/spool/postfix/private/dovecot-lmtp {
    group = postfix
    user = postfix
    mode = 0666
  }
service auth {
  # Postfix smtp-auth
  unix_listener /var/spool/postfix/private/auth {
    mode = 0666
    user = postfix
    group = postfix
  }
==== 10-auth.conf ====
nano 10-auth.conf
  * 
disable_plaintext_auth = yes
# Today however many people use SSL/TLS, and there's no problem with sending unencrypted password inside SSL secured connections.
auth_mechanisms = plain login
#!include auth-system.conf.ext
#!include auth-sql.conf.ext
#!include auth-ldap.conf.ext
!include auth-passwdfile.conf.ext
#!include auth-checkpassword.conf.ext
#!include auth-vpopmail.conf.ext
#!include auth-static.conf.ext
==== auth-passwdfile.conf.ext ====
nano auth-passwdfile.conf.ext
  * 
# Authentication for passwd-file users. Included from 10-auth.conf.
#
# passwd-like file with specified location.
# 
passdb {
  driver = passwd-file
  args = scheme=SHA512-CRYPT username_format=%u /etc/dovecot/dovecot-users
}
userdb {
  driver = static
  args = uid=vmail gid=vmail home=/var/mail/vhosts/%d/%n
}
==== Dovecot Users PasswdFile ====
doveadm pw -l
doveadm pw -s SHA512-CRYPT
nano ../dovecot-users
  * 
#meinekleinefarm.net
xenadmin@meinekleinefarm.net:{SHA512-CRYPT}$6$XYZxyzXYZxyzXYZxyzXYZxyzXYZxyzXYZxyzXYZxyzXYZxyzXYZxyzXYZxyz
#mgs-ullrich.de
example@mgs-ullrich.de:{SHA512-CRYPT}$6$XYZxyzXYZxyzXYZxyzXYZxyzXYZxyzXYZxyzXYZxyzXYZxyzXYZxyzXYZxyz
==== 10-ssl.conf ====
nano 10-ssl.conf
  * 
ssl = required
ssl_cert = 
==== 10-logging.conf ====
nano 10-logging.conf
  * 
log_path = /var/log/dovecot.log
==== 15-mailboxes.conf ====
nano 15-mailboxes.conf
  * 
namespace inbox {
  # These mailboxes are widely used and could perhaps be created automatically:
  mailbox Drafts {
    special_use = \Drafts
    auto=subscribe
  }
  mailbox Junk {
    special_use = \Junk
    auto=subscribe
  }
  mailbox Trash {
    special_use = \Trash
    auto=subscribe
  }
  # For \Sent mailboxes there are two widely used names. We'll mark both of
  # them as \Sent. User typically deletes one of them if duplicates are created.
  mailbox Sent {
    special_use = \Sent
    auto=subscribe
  }
  mailbox "Sent Messages" {
    special_use = \Sent
  }
  # If you have a virtual "All messages" mailbox:
  #mailbox virtual/All {
  #  special_use = \All
  #  comment = All my messages
  #}
  # If you have a virtual "Flagged" mailbox:
  mailbox virtual/Flagged {
    special_use = \Flagged
    auto=no
    comment = All my flagged messages
  }
}
==== Setup logrotate ====
nano /etc/logrotate.d/dovecot
  * 
/var/log/dovecot*.log {
  missingok
  notifempty
  delaycompress
  sharedscripts
  postrotate
    doveadm log reopen
  endscript
}
==== Fin ====
systemctl restart dovecot