Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

DOVECOT.txt 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. #
  2. # Dovecot configuration for Postfix Admin
  3. # Originally written by: Massimo <AndyCapp> Danieli
  4. # Revised by: Sampsa Hario <shario> for Dovecot v1.0
  5. # Revised by: David Goodwin <david@palepurple.co.uk> for Dovecot 2.1.x (2014/01/02)
  6. #
  7. More complete Dovecot documentation:
  8. http://wiki.dovecot.org/Quota
  9. http://wiki.dovecot.org/Quota/Dict
  10. http://www.opensourcehowto.org/how-to/mysql/mysql-users-postfixadmin-postfix-dovecot--squirrelmail-with-userprefs-stored-in-mysql.html
  11. Here are the relevant parts of Dovecot v2.1.x configuration for Postfixadmin setup.
  12. Please refer to Dovecot documentation for complete information.
  13. The setup gets userdb and passdb info from MySQL as well as quotas, and
  14. uses dict backend to store used quotas as key=value pairs so that they can
  15. be viewed real-time in Postfixadmin.
  16. 1. Dovecot setup
  17. -----------------
  18. A basic /etc/dovecot/dovecot.conf is as follows, this was generated using 'dovecot -n' on a vanilla install and then
  19. changing to talk to a PostgreSQL or MySQL database.
  20. # BEGIN /etc/dovecot/dovecot.conf:
  21. # Change this to where your mail root is, this needs to match whatever structure postfix expects....
  22. mail_location = maildir:/var/mail/vmail/%u/
  23. namespace inbox {
  24. inbox = yes
  25. location =
  26. mailbox Drafts {
  27. special_use = \Drafts
  28. }
  29. mailbox Junk {
  30. special_use = \Junk
  31. }
  32. mailbox Sent {
  33. special_use = \Sent
  34. }
  35. mailbox "Sent Messages" {
  36. special_use = \Sent
  37. }
  38. mailbox Trash {
  39. special_use = \Trash
  40. }
  41. prefix =
  42. }
  43. protocols = "imap pop3"
  44. # change to 'no' if you don't have ssl cert/keys, and comment out ssl_cert/ssl_key
  45. ssl = yes
  46. ssl_cert = </etc/dovecot/private/dovecot.pem
  47. ssl_key = </etc/dovecot/private/dovecot.pem
  48. # login is for outlook express smtpd auth
  49. auth_mechanisms = plain login
  50. # If you're having trouble, try uncommenting these :
  51. #auth_debug = yes
  52. #auth_debug_passwords = yes
  53. userdb {
  54. driver = sql
  55. args = /etc/dovecot/dovecot-sql.conf
  56. }
  57. passdb {
  58. driver = sql
  59. args = /etc/dovecot/dovecot-sql.conf
  60. }
  61. # Uncomment this if you want Postfix to be able to do smtpd auth through dovecot
  62. # At a minimum Postfix probably needs : smtpd_sasl_type = dovecot
  63. # And additionally: smtpd_sasl_path = private/auth
  64. #service auth {
  65. # unix_listener /var/spool/postfix/private/auth {
  66. # mode = 0660
  67. # user = postfix
  68. # group = postfix
  69. # }
  70. # user = postfix
  71. # group = postfix
  72. #}
  73. # Needs to match Postfix virtual_uid_maps
  74. first_valid_uid = 1001
  75. # allow plaintext auth (change to 'yes' to block plaintext passwords)
  76. disable_plaintext_auth = no
  77. #END
  78. 2. Dovecot *sql setup
  79. ----------------------
  80. Below you'll find the relevant part of dovecot-sql.conf file regarding our
  81. setup.
  82. Things you will probably need to change are db connection settings (connect=)
  83. and the default_pass_scheme.
  84. #BEGIN /etc/dovecot/dovecot-sql.conf
  85. connect = host=localhost dbname=postfix user=postfix password=postfix
  86. # Use either
  87. driver = mysql
  88. # Or
  89. # driver = pgsql
  90. # Default password scheme - change to match your Postfixadmin setting.
  91. # depends on your $CONF['encrypt'] setting:
  92. # md5crypt -> MD5-CRYPT
  93. # md5 -> PLAIN-MD5
  94. # cleartext -> PLAIN
  95. default_pass_scheme = MD5-CRYPT
  96. # Query to retrieve password. user can be used to retrieve username in other
  97. # formats also.
  98. password_query = SELECT username AS user,password FROM mailbox WHERE username = '%u' AND active='1'
  99. # Query to retrieve user information, note uid matches dovecot.conf AND Postfix virtual_uid_maps parameter.
  100. user_query = SELECT maildir, 1001 AS uid, 1001 AS gid FROM mailbox WHERE username = '%u' AND active='1'
  101. # MYSQL :
  102. user_query = SELECT CONCAT('/var/vmail/mail/', maildir) AS home, 1001 AS uid, 1001 AS gid,
  103. CONCAT('*:bytes=', quota) AS quota_rule FROM mailbox WHERE username = '%u' AND active='1'
  104. # PostgreSQL : (no Quota though) :
  105. # user_query = SELECT '/var/vmail/mail/' || maildir AS home, 1001 as uid, 1001 as gid FROM mailbox WHERE username = '%u' AND active = '1'
  106. #END /etc/dovecot/dovecot-sql.conf
  107. 3. Dovecot v1.0 quota support (optional)
  108. ----------------------------------------
  109. Please note that you need to use Dovecot's own local delivery agent to
  110. enforce and update quotas. Then you can view real-time used quotas in
  111. Postfixadmin.
  112. Add to dovecot.conf:
  113. ## IMAP quota
  114. protocol imap {
  115. quota = dict:storage=200000 proxy::quota
  116. }
  117. ## POP quota
  118. protocol pop3 {
  119. mail_plugins = quota
  120. }
  121. ## Local Delivery Agent
  122. protocol lda {
  123. mail_plugins = quota
  124. }
  125. ## Dictionary DB proxy
  126. dict {
  127. quota = mysql:/etc/dovecot-dict-quota.conf
  128. }
  129. ## Default quota values
  130. plugin {
  131. quota = dict:storage=200000 proxy::quota
  132. }
  133. Change dovecot-sql.conf to return quota values:
  134. for MySQL:
  135. user_query = SELECT maildir, 1001 AS uid, 1001 AS gid, CONCAT('dict:storage=',floor(quota/1000),' proxy::quota') as quota FROM mailbox WHERE username = '%u' AND active='1'
  136. for PostgreSQL:
  137. user_query = SELECT maildir, 1001 AS uid, 1001 AS gid, 'dict:storage=' || floor(quota/1000) || '::proxy::quota' as quota FROM mailbox WHERE username = '%u' AND active='1'
  138. Create file dovecot-dict-quota.conf:
  139. driver = mysql
  140. connect = host=localhost dbname=postfix user=postfix password=postfix
  141. default_pass_scheme = MD5-CRYPT
  142. table = quota
  143. select_field = current
  144. where_field = path
  145. username_field = username
  146. Create database in Mysql:
  147. (This is automatically done by postfixadmin's setup.php)
  148. Enable quota support in Postfixadmin config.inc.php:
  149. $CONF['used_quotas'] = 'YES';
  150. $CONF['quota'] = 'YES';
  151. Note: The above text describes the configuration for dovecot 1.0 & 1.1 quota table format.
  152. If you use dovecot 1.2 or newer,
  153. - use the 'quota2' table (also created by setup.php)
  154. - set $CONF['new_quota_table'] = 'YES'