Linux/Mailserver/Small Office Smarthost

From Wiki

This configuration is based on Ubuntu 12.04 LTS

  • preparing the system
mkdir /srv/mail/virtual
groupadd -g 5000 vmail
useradd -s /usr/sbin/nologin -u 5000 -g 5000 vmail
id vmail

postfix

smtpd_sasl_type = dovecot

  1. Can be an absolute path, or relative to $queue_directory
  2. Debian/Ubuntu users: Postfix is setup by default to run chrooted, so it is best to leave it as-is below

smtpd_sasl_path = private/auth

  1. and the common settings to enable SASL:

smtpd_sasl_auth_enable = yes smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination

dovecot

  • /etc/dovecot/conf.d/10-auth.conf
auth_mechanisms = plain            # optional: login

#!include auth-master.conf.ext     # disable
!include auth-passwdfile.conf.ext
  • /etc/dovecot/conf.d/10-logging.conf
log_path = /var/log/dovecot

auth_debug = yes    # for debugging only
mail_debug = yes    #
verbose_ssl = yes   #
  • /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:/srv/mail/virtual/%d/%n
  • /etc/dovecot/conf.d/10-master.conf
service auth {
...
  unix_listener /var/spool/postfix/private/auth {
    mode = 0660
    # Assuming the default Postfix user and group
    user = postfix
    group = postfix        
  }
  ...
}
  • /etc/dovecot/conf.d/auth-passwdfile.conf.ext
passdb {
  driver = passwd-file
  args = /srv/mail/virtual/%d/passdb
}
userdb {
  driver = passwd-file
  args = /srv/mail/virtual/%d/userdb
}


touch /var/log/dovecot
chown vmail:vmail /var/log/dovecot
chmod 660