Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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