2. Dovecot installation and configuration

Dovecot allows e-mail retrieval through POP3 and/or IMAP protocols, optionally secured with TLS. Dovecot installation requires to install the dovecot package

Dovecot package insta‏‏‎‎‏‎‏‎‎‎‏‎‏‏‏‏‏‎‎‎‎‎‏‎‏‎‎‏‏‏‏‏‏‏‎‏‎‎‏‎‎‎‏‎‎‏‏‏‏‏‎‎‎‏‏llation‏‎‎‏

# yum install dovecot

followed by configuration. Below is a simple dovecot configuration file which allows user credentials to be retrieved from a MySQL database, and few other parameters: mail location, user id, group id, ip address list allowed for client connection, etc. For now, I don't want TLS support, so I'll enable only the standard mail retrieval protocols.
Below is the /etc/dovecot.conf file contents:

D‎‏‎‎‎‎‎‏‎‎‎‎‎‎‎‎‎‎‏‎‎‏‎‎‎‏‏‏‏‏‏‎‏‏‏‏‏‏‎‏‏‎‎‏‎‏‎‎‎‏‎‏‏‏‏‏‎‎‎‎‎‏‎‏‎‎‏‏‏‏‏‏‏‎‏‎‎‏‎‎‎‏‎‎‏‏‏‏‏‎‎‎‏‏‎ovecot configuration file‏: /etc/dovecot.conf

protocols = imap pop3
listen =
ssl_disable = yes
mail_location = maildir:~/
mail_debug = no
verbose_proctitle = yes
first_valid_uid = 89
last_valid_uid = 89
first_valid_gid = 89
last_valid_gid = 89
maildir_copy_with_hardlinks = yes
protocol imap {
  mail_plugins = quota imap_quota
  imap_client_workarounds = delay-newmail outlook-idle netscape-eoh tb-extra-mailbox-sep
protocol pop3 {
  pop3_uidl_format = %08Xu%08Xv
  pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
protocol lda {
  postmaster_address = postmaster@mydomain.com
  hostname = mx1.mydomain.com
  auth_socket_path = /var/run/dovecot/auth-master
auth_executable = /usr/libexec/dovecot/dovecot-auth
auth_username_chars = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@
auth_debug = no
auth default {
  mechanisms = plain login
  passdb sql {
    args = /etc/dovecot-mysql.conf
  userdb prefetch {
  userdb sql {
    args = /etc/dovecot-mysql.conf
  user = nobody
  socket listen {
    client {
      path = /var/spool/postfix/private/auth
      mode = 0666
      user = postfix
      group = postfix
dict {
plugin {
  quota = maildir

As you can see, the authentication system relies on a MySQL database. I've configured the SASL authentication socket, accesible for postfix. The parameters required for database connection are included in the /etc/dovecot-mysql.conf file, it's content is shown below:

/etc/dovecot-mysql.conf file contents‏‎‎‎‎‎‏‎‎‎‎‎‎‎‎‎‎‏‎‎‏‎‎‎‏‏‏‏‏‏‎‏‏‏‏‏‏‎‏‏‎‎‏‎‏‎‎‎‏‎‏‏‏‏‏‎‎‎‏‎‏‎‎‏‏‏‏‏‏‏‎‏‎‎‏‎‎‎‏‎‎‏‏‏‏‏‏

# dovecot ver = 1.0.7 - 1.1.3 compatible
connect = host= port=3306 user=postfix password=Postfix_Database_Password dbname=postfix
driver = mysql
default_pass_scheme = MD5-CRYPT
password_query = SELECT password,CONCAT('/mail/', maildir) AS userdb_home, '89' AS userdb_uid, '89' AS userdb_gid, NULL as allow_nets FROM mailbox WHERE username = '%u' AND domain = '%d' AND active = '1'
user_query = SELECT CONCAT('/mail/', maildir) AS home, '' as mail, '89' AS uid, '89' AS gid, ROUND ( quota / 1024 ) AS quota FROM mailbox WHERE username = %u AND domain = %d

In my example, I put the e-mails below a directory /mail. Your setup can be different, you cah choose whatever root location you like for e-mail placement on the filesystems. The user is and group id are the UID and GID of the postfix user in a default CentOS installation.

Up: CentOS Mail Server setup: Postfix, Dovecot, MySQL, SASL, Postfixadmin, TLS
Prev: MySQL Database installation
Next: Dovecot configuration for multiple domains