Added on May 18th, 2012 and marked as dovecot install mail

Add the following two lines to the bottom of /etc/postfix/master.cf:

dovecot   unix  -       n       n       -       -       pipe
    flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -d ${recipient}

You can check the current dovecot configuration with:

doveconf -n

This should look something like this:

# 2.2.9: /etc/dovecot/dovecot.conf
# OS: Linux 3.13.0-43-generic x86_64 Ubuntu 14.04.2 LTS ext4
log_timestamp = "%Y-%m-%d %H:%M:%S "
mail_location = maildir:/home/vmail/%d/%n
namespace {
  inbox = yes
  location =
  prefix = INBOX.
  separator = .
  type = private
}
passdb {
  args = /etc/dovecot/dovecot-sql.conf
  driver = sql
}
protocols = imap pop3
service auth {
  unix_listener /var/spool/postfix/private/auth {
    group = postfix
    mode = 0660
    user = postfix
  }
  unix_listener auth-master {
    mode = 0600
    user = vmail
  }
  user = root
}
ssl_cert = </etc/ssl/certs/dovecot.pem
ssl_key = </etc/ssl/private/dovecot.pem
userdb {
  args = uid=5000 gid=5000 home=/home/vmail/%d/%n allow_all_users=yes
  driver = static
}
protocol lda {
  auth_socket_path = /var/run/dovecot/auth-master
  log_path = /var/log/dovecot.log
  postmaster_address = [email protected]
}
protocol pop3 {
  pop3_uidl_format = %08Xu%08Xv
}

If it doesn’t add the lines above to the files /etc/dovecot/dovecont.conf.

If you later see errors like these in the mail.log:

Disconnected (tried to use disabled plaintext auth)

you could decide to add the following line to dovecot.conf in order to accept plaintext logins over an insecure connection:

disable_plaintext_auth = no

Replace the content (if any) of /etc/dovecot/dovecot-sql.conf with the following lines (remember to specify your own password):

driver = mysql
connect = host=127.0.0.1 dbname=mailserver user=mail_user password=mail_user_password
default_pass_scheme = CRYPT
password_query = SELECT email as user, password FROM users WHERE email='%u';

Change the permissions of the dovecot config file:

chgrp vmail /etc/dovecot/dovecot.conf
chmod g+r /etc/dovecot/dovecot.conf

Make sure the log-file is writable for the user vmail:

touch /var/log/dovecot.log
chown vmail:vmail /var/log/dovecot.log

Restart dovecot:

service dovecot restart