doc/web/source/installation/dovecot_configuration.rst
changeset 579 be0906181a10
child 581 9c138471d569
equal deleted inserted replaced
578:20141b967c0b 579:be0906181a10
       
     1 =====================
       
     2 Dovecot configuration
       
     3 =====================
       
     4 This page describes in short how to configure Dovecot.
       
     5 
       
     6 If you are upgrading your Dovecot installation from v1.\ **1**.x to
       
     7 v1.\ **2**.x or v\ **1**.x to v\ **2**.x, you should also read Upgrading_
       
     8 in the `Dovecot wiki`_.
       
     9 
       
    10 Dovecot v1.x
       
    11 ------------
       
    12 This setup uses two configuration files.
       
    13 :file:`dovecot.conf`, the MainConfig_ of the Dovecot server and
       
    14 :file:`dovecot-sql.conf`, containing the settings for passdb_ and userdb_
       
    15 lookups.
       
    16 For more details see also `AuthDatabase/SQL`_ in the Dovecot wiki.
       
    17 
       
    18 dovecot.conf
       
    19 ^^^^^^^^^^^^
       
    20 The following configuration example can be used as complete configuration
       
    21 file. You can also adjust your existing settings.
       
    22 Use :command:`dovecot -n | head -n 1` to locate your :file:`dovecot.conf`.
       
    23 
       
    24 .. note:: Please modify the `postmaster_address` to meet your specific needs.
       
    25 
       
    26 .. code-block:: text
       
    27 
       
    28  # all your other settings
       
    29  #disable_plaintext_auth = no
       
    30  mail_location = maildir:~/Maildir
       
    31  first_valid_uid = 70000
       
    32  first_valid_gid = 70000
       
    33  protocol lda {
       
    34    postmaster_address = postmaster@YOUR-DOMAIN.TLD
       
    35    # uncomment this to use server side filtering (Dovecot v1.0.x/v1.1.x)
       
    36    #mail_plugins = cmusieve
       
    37    # uncomment this to use server side filtering (Dovecot v1.2.x)
       
    38    #mail_plugins = sieve
       
    39  }
       
    40  protocol pop3 {
       
    41    pop3_uidl_format = %08Xu%08Xv
       
    42  }
       
    43  # uncomment this to use the ManageSieve protocol, if supported by your installation
       
    44  #protocol managesieve {
       
    45  #  # only valid with Dovecot v1.0.x/v1.1.x.
       
    46  #  # see also: http://wiki.dovecot.org/ManageSieve/Configuration#v1.0.2BAC8-v1.1
       
    47  #  sieve = ~/.dovecot.sieve
       
    48  #  sieve_storage = ~/sieve
       
    49  #}
       
    50  auth default {
       
    51    mechanisms = cram-md5 login plain
       
    52    passdb sql {
       
    53      args = /etc/dovecot/dovecot-sql.conf
       
    54    }
       
    55    userdb sql {
       
    56      args = /etc/dovecot/dovecot-sql.conf
       
    57    }
       
    58    user = doveauth
       
    59    socket listen {
       
    60      master {
       
    61        path = /var/run/dovecot/auth-master
       
    62        mode = 0600
       
    63      }
       
    64      client {
       
    65        path = /var/spool/postfix/private/dovecot-auth
       
    66        mode = 0660
       
    67        user = postfix
       
    68        group = postfix
       
    69      }
       
    70    }
       
    71  }
       
    72  # uncomment this if you use the ManageSieve protocol with Dovecot v1.2.x
       
    73  #plugin {
       
    74  #  # Sieve and ManageSieve settings
       
    75  #  # see also: http://wiki.dovecot.org/ManageSieve/Configuration#v1.2
       
    76  #  sieve = ~/.dovecot.sieve
       
    77  #  sieve_dir = ~/sieve
       
    78  #}
       
    79 
       
    80 
       
    81 .. _dovecot-sql-conf:
       
    82 
       
    83 dovecot-sql.conf
       
    84 ^^^^^^^^^^^^^^^^
       
    85 This lines contains all information that are required by Dovecot to access
       
    86 the database and to do the lookups in passdb and userdb.
       
    87 
       
    88 .. code-block:: text
       
    89 
       
    90  driver = pgsql
       
    91  connect = host=localhost dbname=mailsys user=dovecot password=$Dovecot_PASS
       
    92  default_pass_scheme = CRAM-MD5
       
    93  password_query = SELECT userid AS "user", password FROM dovecotpassword('%Ln', '%Ld') WHERE %Ls
       
    94  user_query = SELECT SELECT home, uid, gid, mail FROM dovecotuser('%Ln', '%Ld')
       
    95 
       
    96 Dovecot v2.x
       
    97 ------------
       
    98 Beginning with Dovecot version 2.0 the configuration was split into multiple
       
    99 files.
       
   100 It isn't required to use multiple configuration files.
       
   101 :file:`dovecot.conf` is still the most important configuration file.
       
   102 Use the command :command:`doveconf -n | head -n 1` to locate your
       
   103 :file:`dovecot.conf`.
       
   104 You could put all settings in your :file:`dovecot.conf`.
       
   105 You can also include multiple files into your :file:`dovecot.conf`.
       
   106 
       
   107 I personally prefer it to comment out most of the :file:`dovecot.conf`
       
   108 and include only my :file:`local.conf`, which contains all the necessary 
       
   109 settings.
       
   110 You can download my :download:`local.conf <../_static/local.conf>` and use
       
   111 it in your setup.
       
   112 
       
   113 If you want to use multiple configuration files, you have to apply the
       
   114 following settings to the configuration files mentioned down below.
       
   115 Everything that isn't mentioned, was commented out.
       
   116 
       
   117 .. _dovecot2.conf:
       
   118 
       
   119 dovecot.conf
       
   120 ^^^^^^^^^^^^
       
   121 .. code-block:: text
       
   122 
       
   123  protocols = imap lmtp
       
   124  # uncomment if your users should be able to manage their sieve scripts
       
   125  #protocols = imap lmtp sieve
       
   126 
       
   127  # uncomment if you want to use the quota plugin
       
   128  #dict {
       
   129  #  quota = pgsql:/usr/local/etc/dovecot/dovecot-dict-sql.conf.ext
       
   130  #}
       
   131 
       
   132 See also :ref:`dovecot-dict-sql-conf-ext` below.
       
   133 
       
   134 .. warning:: Adjust the paths of the :file:`dovecot-dict-sql.conf.ext`
       
   135    (above) and :file:`dovecot-sql.conf.ext` (below) files to suit your needs.
       
   136 
       
   137 
       
   138 .. _conf-d-10-auth-conf:
       
   139 
       
   140 conf.d/10-auth.conf
       
   141 ^^^^^^^^^^^^^^^^^^^
       
   142 .. code-block:: text
       
   143 
       
   144  auth_mechanisms = plain login cram-md5
       
   145  passdb {
       
   146    driver = sql
       
   147    args = /usr/local/etc/dovecot/dovecot-sql.conf.ext
       
   148  }
       
   149  userdb {
       
   150    driver = sql
       
   151    args = /usr/local/etc/dovecot/dovecot-sql.conf.ext
       
   152  }
       
   153  #!include auth-system.conf.ext
       
   154 
       
   155 See also :ref:`dovecot-sql-conf-ext` below.
       
   156 
       
   157 
       
   158 conf.d/10-mail.conf
       
   159 ^^^^^^^^^^^^^^^^^^^
       
   160 .. code-block:: text
       
   161 
       
   162  first_valid_gid = 70000
       
   163  first_valid_uid = 70000
       
   164  mail_access_groups = dovemail
       
   165  mail_location = maildir:~/Maildir
       
   166  
       
   167  # uncomment if you want to use the quota plugin
       
   168  #mail_plugins = quota
       
   169 
       
   170 conf.d/10-master.conf
       
   171 ^^^^^^^^^^^^^^^^^^^^^
       
   172 .. code-block:: text
       
   173 
       
   174  # if you don't want to use secure imap, you have to disable the imaps listener
       
   175  ##service imap-login {
       
   176  ##  inet_listener imaps {
       
   177  ##    port = 0
       
   178  ##  }
       
   179  ##}
       
   180 
       
   181  service lmtp {
       
   182    unix_listener /var/spool/postfix/private/dovecot-lmtp {
       
   183      user = postfix
       
   184      group = postfix
       
   185      mode = 0600
       
   186    }
       
   187  }
       
   188 
       
   189  service auth {
       
   190    user = doveauth
       
   191    unix_listener auth-userdb {
       
   192    }
       
   193    unix_listener /var/spool/postfix/private/dovecot-auth {
       
   194      user = postfix
       
   195      group = postfix
       
   196      mode = 0600
       
   197    }
       
   198  }
       
   199 
       
   200  service auth-worker {
       
   201    unix_listener auth-worker {
       
   202      user = doveauth
       
   203      group = $default_internal_user
       
   204      mode = 0660
       
   205    }
       
   206    user = doveauth
       
   207  }
       
   208 
       
   209  service dict {
       
   210    unix_listener dict {
       
   211      group = dovemail
       
   212      mode = 0660
       
   213    }
       
   214  }
       
   215 
       
   216 conf.d/10-ssl.conf
       
   217 ^^^^^^^^^^^^^^^^^^
       
   218 .. code-block:: text
       
   219 
       
   220  # SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>
       
   221  #ssl = yes
       
   222 
       
   223  ssl_cert = </etc/ssl/certs/dovecot.pem
       
   224  ssl_key = </etc/ssl/private/dovecot.pem
       
   225 
       
   226  # if you want to disable SSL/TLS, you have set 'ssl = no' and disable the
       
   227  # imaps listener in conf.d/10-master.conf
       
   228 
       
   229 conf.d/15-lda.conf
       
   230 ^^^^^^^^^^^^^^^^^^
       
   231 .. note:: Please modify the `postmaster_address` to meet your specific needs.
       
   232 
       
   233 .. code-block:: text
       
   234 
       
   235  postmaster_address = postmaster@YOUR-DOMAIN.TLD
       
   236  recipient_delimiter = +
       
   237  protocol lda {
       
   238    # uncomment if you want to use the quota plugin
       
   239    #mail_plugins = $mail_plugins
       
   240    # uncomment if you want to use the quota and sieve plugins
       
   241    #mail_plugins = $mail_plugins sieve
       
   242  }
       
   243 
       
   244 conf.d/20-imap.conf
       
   245 ^^^^^^^^^^^^^^^^^^^
       
   246 .. code-block:: text
       
   247 
       
   248  protocol imap {
       
   249    # uncomment if you want to use the quota plugin
       
   250    #mail_plugins = $mail_plugins imap_quota
       
   251  }
       
   252 
       
   253 conf.d/20-lmtp.conf
       
   254 ^^^^^^^^^^^^^^^^^^^
       
   255 .. code-block:: text
       
   256 
       
   257  protocol lmtp {
       
   258    # uncomment if you want to use the quota plugin
       
   259    #mail_plugins = $mail_plugins
       
   260    # uncomment if you want to use the quota and sieve plugins
       
   261    #mail_plugins = $mail_plugins sieve
       
   262  }
       
   263 
       
   264 conf.d/90-quota.conf
       
   265 ^^^^^^^^^^^^^^^^^^^^
       
   266 .. code-block:: text
       
   267 
       
   268  # uncomment if you want to use the quota plugin
       
   269  #plugin {
       
   270  #  quota = dict:user:%{uid}::proxy::quota
       
   271  #  quota_rule = *:storage=0:messages=0
       
   272  #  quota_rule2 = Trash:storage=+100M
       
   273  #}
       
   274 
       
   275 conf.d/90-sieve.conf
       
   276 ^^^^^^^^^^^^^^^^^^^^
       
   277 .. code-block:: text
       
   278 
       
   279  # uncomment if you want to use sieve (and maybe managesieve)
       
   280  #plugin {
       
   281  #  recipient_delimiter = +
       
   282  #  sieve = ~/.dovecot.sieve
       
   283  #  sieve_dir = ~/sieve
       
   284  #}
       
   285 
       
   286 
       
   287 .. _dovecot-sql-conf-ext:
       
   288 
       
   289 dovecot-sql.conf.ext
       
   290 ^^^^^^^^^^^^^^^^^^^^
       
   291 This file was referenced above in the `passdb` and `userdb` sections of
       
   292 :ref:`conf-d-10-auth-conf`.
       
   293 
       
   294 .. code-block:: text
       
   295 
       
   296  driver = pgsql
       
   297  connect = host=localhost dbname=mailsys user=dovecot password=$Dovecot_PASS
       
   298  
       
   299  password_query = \
       
   300   SELECT userid AS "user", password FROM dovecotpassword('%Ln', '%Ld') WHERE %Ls
       
   301  
       
   302  # uncomment this user_query if you want to use the quota plugin
       
   303  #user_query = \
       
   304  # SELECT home, uid, gid, mail, quota_rule FROM dovecotquotauser('%Ln', '%Ld')
       
   305 
       
   306  # otherwise uncomment the following user_query
       
   307  #user_query = SELECT home, uid, gid, mail FROM dovecotuser('%Ln', '%Ld')
       
   308  
       
   309  iterate_query = \
       
   310   SELECT local_part AS username, domain_name.domainname AS domain \
       
   311     FROM users \
       
   312          LEFT JOIN domain_data USING (gid) \
       
   313          LEFT JOIN domain_name USING (gid)
       
   314 
       
   315 
       
   316 .. _dovecot-dict-sql-conf-ext:
       
   317 
       
   318 dovecot-dict-sql.conf.ext
       
   319 ^^^^^^^^^^^^^^^^^^^^^^^^^
       
   320 If you want to use the quota plugin add this lines to your
       
   321 :file:`dovecot-dict-sql.conf.ext`.
       
   322 This file was referenced in the `dict` section of :ref:`dovecot2.conf`.
       
   323 
       
   324 .. code-block:: text
       
   325 
       
   326  connect = host=localhost dbname=mailsys user=dovecot password=$Dovecot_PASS
       
   327  map {
       
   328    pattern = priv/quota/storage
       
   329    table = userquota
       
   330    username_field = uid
       
   331    value_field = bytes
       
   332  }
       
   333  map {
       
   334    pattern = priv/quota/messages
       
   335    table = userquota
       
   336    username_field = uid
       
   337    value_field = messages
       
   338  }
       
   339 
       
   340 .. include:: ../ext_references.rst