Author Topic: help configuring quota with dovecot  (Read 9164 times)

Offline imax36581

  • Newbie
  • *
  • Posts: 9
help configuring quota with dovecot
« on: July 25, 2012, 01:49:03 AM »
Hi all
i use postfix+postfixadmin+dovecot+roundcube for my mail installation.
i have some problem in displaying quota in roundcube.postfixadmin show users quota truly, but roundcube show unlimited.
i tried searching in forum but i can't find something related to my issue.
here is my configuration in dovecot:
Dovecot to access mysql:
dovecot-mysql.conf:
Code: [Select]

driver = mysql
connect = host=localhost dbname=postfix user=postfix password=yourpassword
default_pass_scheme = MD5-CRYPT

# following should all be on one line.
password_query = SELECT username as user, password, concat('/home/vmail/', maildir) as userdb_home,
concat('maildir:/home/vmail/', maildir) as userdb_mail, 101 as userdb_uid, 12 as userdb_gid FROM mailbox
WHERE username = '%u' AND active = '1'

# following should all be on one line
user_query = SELECT concat('/home/vmail/', maildir) as home, concat('maildir:/home/vmail/', maildir) as mail,
101 AS uid, 12 AS gid, CONCAT('*:messages=10000:bytes=', quota) as quota_rule FROM mailbox WHERE
username = '%u' AND active = '1'

and /etc/dovecot/dovecot-dict-quota.conf:

Code: [Select]
connect = host=localhost dbname=postfix user=postfix password=password
map {
  pattern = priv/quota/storage
  table = quota2
  username_field = username
  value_field = bytes
}
map {
  pattern = priv/quota/messages
  table = quota2
  username_field = username
  value_field = messages
}


and my dovecot configuration file:

Code: [Select]

##
## Dovecot config file
##

protocols = imap pop3 lmtp sieve
auth_mechanisms = plain login
passdb {
  driver = sql
  args = /etc/dovecot/dovecot-mysql.conf
}
userdb {
  driver = prefetch
}
userdb {
  driver = sql
  args = /etc/dovecot/dovecot-mysql.conf
}
mail_location = maildir:/home/vmail/%d/%n
first_valid_uid = 101
#last_valid_uid = 0
first_valid_gid = 12
#last_valid_gid = 0
#mail_plugins =
mailbox_idle_check_interval = 30 secs
maildir_copy_with_hardlinks = yes
service imap-login {
  inet_listener imap {
    port = 143
  }
  inet_listener imaps {
    port = 993
    ssl = yes
  }
}
service pop3-login {
  inet_listener pop3 {
    port = 110
  }
  inet_listener pop3s {
    port = 995
    ssl = yes
  }
}
service lmtp {
  unix_listener lmtp {
    #mode = 0666
  }
}
service imap {
  vsz_limit = 256M
}
service pop3 {
}
service auth {
  unix_listener auth-userdb {
    mode = 0666
    user = vmail
    group = mail
  }

  # Postfix smtp-auth
  unix_listener /var/spool/postfix/private/auth {
    mode = 0666
    user = postfix
    group = postfix
  }
}
service auth-worker {
}
service dict {
  unix_listener dict {
    mode = 0666
    user = vmail
    group = mail
  }
}
service managesieve-login {
  inet_listener sieve {
    port = 4190
  }
  service_count = 1
  process_min_avail = 0
  vsz_limit = 64M
}
service managesieve {
}
ssl = yes
ssl_cert = </etc/pki/tls/certs/your-server.your-domain.tld.crt
ssl_key = </etc/pki/tls/private/your-server.your-domain.tld.key
ssl_verify_client_cert = no
#ssl_ca =
lda_mailbox_autocreate = yes         
lda_mailbox_autosubscribe = yes
protocol lda {
  mail_plugins = quota sieve
  postmaster_address = postmaster@your-domain.tld

protocol imap {
  mail_plugins = quota imap_quota trash
  imap_client_workarounds = delay-newmail
}
lmtp_save_to_detail_mailbox = yes
protocol lmtp {
  mail_plugins = sieve
}
protocol pop3 {
  mail_plugins = quota
  pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
}
protocol sieve {
  managesieve_max_line_length = 65536
  managesieve_implementation_string = Dovecot Pigeonhole
  managesieve_max_compile_errors = 5
}
dict {
  quotadict = mysql:/etc/dovecot/dovecot-dict-quota.conf
}
plugin {
  quota = dict:user::proxy::quotadict
  acl = vfile:/etc/dovecot/acls
  trash = /etc/dovecot/trash.conf
  sieve_global_path = /home/sieve/globalfilter.sieve
  sieve = ~/dovecot.sieve
  sieve_dir = ~/sieve
  sieve_global_dir = /home/sieve/
  #sieve_extensions = +notify +imapflags
  sieve_max_script_size = 1M
  #sieve_max_actions = 32
  #sieve_max_redirects = 4
}

and my roundcube quota change:
Code: [Select]
$rcmail_config['quota_zero_as_unlimited'] = false;
change to:
 
Code: [Select]
$rcmail_config['quota_zero_as_unlimited'] = true;
i will appreciate any help.
thanks in advance.

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,554
    • http://SKaero.com/
Re: help configuring quota with dovecot
« Reply #1 on: July 25, 2012, 03:30:31 PM »
Enable imap_debug and post the log when you login.

Offline imax36581

  • Newbie
  • *
  • Posts: 9
Re: help configuring quota with dovecot
« Reply #2 on: July 30, 2012, 12:53:32 PM »
sorry for newbie question  :-[
where can i enable debug mode and where is log file located?

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,554
    • http://SKaero.com/
Re: help configuring quota with dovecot
« Reply #3 on: July 30, 2012, 01:10:09 PM »
In the <RC root>/config/main.inc.php file there is a option called imap_debug set it to true and it should create a log of the imap conversation in <RC root>/logs/imap

Offline imax36581

  • Newbie
  • *
  • Posts: 9
Re: help configuring quota with dovecot
« Reply #4 on: July 31, 2012, 08:11:47 AM »
i enabled imap_debug but there is no log files under logs directory of roundcube
is there anything else that i should do?
thanks in advance

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,554
    • http://SKaero.com/
Re: help configuring quota with dovecot
« Reply #5 on: July 31, 2012, 03:34:30 PM »
Make sure the logs directory is writable.

Offline imax36581

  • Newbie
  • *
  • Posts: 9
Re: help configuring quota with dovecot
« Reply #6 on: August 04, 2012, 05:34:20 AM »
sorry for delay
here you are, i attached the imap log file.
thanks for your help in advance

Offline imax36581

  • Newbie
  • *
  • Posts: 9
Re: help configuring quota with dovecot
« Reply #7 on: August 05, 2012, 03:00:09 PM »
any help will be appreciated

Offline Yoni

  • Full Member
  • ***
  • Posts: 164
    • MyRoundcube
Re: help configuring quota with dovecot
« Reply #8 on: August 05, 2012, 05:03:24 PM »
I must admit that I had a hard time with dovecot to get this to work. Here is my dovecot-mysql:

Code: [Select]
connect = host=localhost dbname=postfix user=postfix password=password
user_query = SELECT '/var/vmail/%d/%n' as home, 'maildir:/var/vmail/%d/%n' as mail, 5000 AS uid, 5000 AS gid, CONCAT('*:bytes=', CAST(quota AS CHAR)) AS quota_rule FROM mailbox WHERE username = '%u' AND active = 1

password_query = SELECT username as user, password, '/var/vmail/%d/%n' as userdb_home, 'maildir:/var/vmail/%d/%n' as userdb_mail, 5000 as userdb_uid, 5000 as userdb_gid, CONCAT('*:bytes=', CAST(quota AS CHAR)) AS userdb_quota_rule FROM mailbox WHERE username = '%u' AND active = 1

This is my dovecot config:


Code: [Select]
protocols = imap imaps pop3 pop3s managesieve

listen = *
syslog_facility = mail

ssl = yes
ssl_cert_file = /etc/ssl/certs/server.crt
ssl_key_file = /etc/ssl/private/server.key

ssl_key_password=  (only if your key file is password protected)
ssl_parameters_regenerate = 168
ssl_cipher_list = ALL:!LOW:!SSLv2:ALL:!aNULL:!ADH:!eNULL:!EXP:RC4+RSA:+HIGH:+MEDIUM

mail_location = mbox:~/vmail:INBOX=/var/vmail/%d/%u
mail_debug = yes

first_valid_uid = 5000
last_valid_uid = 5000

maildir_copy_with_hardlinks = yes

protocol imap {
  login_executable = /usr/lib/dovecot/imap-login
  mail_executable = /usr/lib/dovecot/imap
  imap_max_line_length = 65536
  mail_plugins = quota imap_quota
  mail_plugin_dir = /usr/lib/dovecot/modules/imap
  imap_client_workarounds = outlook-idle delay-newmail
}

protocol pop3 {
  login_executable = /usr/lib/dovecot/pop3-login
  mail_executable = /usr/lib/dovecot/pop3
  pop3_uidl_format = %08Xu%08Xv
  mail_plugins = quota
  mail_plugin_dir = /usr/lib/dovecot/modules/pop3
  pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
}

protocol lda {
  postmaster_address = postmaster@mydomain.com
  mail_plugins = sieve quota
  mail_plugin_dir = /usr/lib/dovecot/modules/lda
  log_path = /var/vmail/dovecot-deliver.log
  sendmail_path = /usr/lib/sendmail
  auth_socket_path = /var/run/dovecot/auth-master
}
auth_username_chars = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@
auth_verbose = no
auth_debug = yes
auth_debug_passwords = no
auth default {
  mechanisms = plain login
  passdb sql {
    args = /etc/dovecot/dovecot-sql.conf
  }
  userdb passwd {
  }
  userdb sql {
    args = /etc/dovecot/dovecot-sql.conf
  }
  user = nobody
  socket listen {
    master {
      path = /var/run/dovecot/auth-master
      mode = 0660
      user = vmail
      group = vmail
    }
    client {
      path = /var/spool/postfix/private/auth
      mode = 0660
      user = postfix
      group = postfix
    }
  }
  !include_try /etc/dovecot/auth.d/*.auth
}
dict {
quotadict = mysql:/etc/dovecot/dovecot-dict-sql.conf
}
plugin {
  quota = maildir:User quota
  quota_rule2 = Trash:ignore
  quota_warning = storage=95%% /var/vmail/quota-warning.sh 95
  quota_warning2 = storage=85%% /var/vmail/quota-warning.sh 85
  quota_warning3 = storage=70%% /var/vmail/quota-warning.sh 70
  sieve_global_path=/var/vmail/default.sieve
  sieve_before = /var/vmail/spam.sieve
  sieve=/var/vmail/%d/%n/.sieve
}
!include_try /etc/dovecot/conf.d/*.conf

and this is the dict-sql

Code: [Select]
connect = host=localhost dbname=postfix user=postfix password=password

# CREATE TABLE quota (
#   username varchar(100) not null,
#   bytes bigint not null default 0,
#   messages integer not null default 0,
#   primary key (username)
# );

map {
  pattern = priv/quota/storage
  table = quota
  username_field = username
  value_field = bytes
}
map {
  pattern = priv/quota/messages
  table = quota
  username_field = username
  value_field = messages
}

# CREATE TABLE expires (
#   username varchar(100) not null,
#   mailbox varchar(255) not null,
#   expire_stamp integer not null,
#   primary key (username, mailbox)
# );

map {
  pattern = shared/expire/$user/$mailbox
  table = expires
  value_field = expire_stamp

  fields {
    username = $user
    mailbox = $mailbox
  }
}
« Last Edit: August 05, 2012, 05:11:02 PM by Yoni »

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,554
    • http://SKaero.com/
Re: help configuring quota with dovecot
« Reply #9 on: August 07, 2012, 03:29:12 AM »
Its a problem with you mail server as shown by the following two lines in the imap log:
Quote
C: A0004 GETQUOTAROOT INBOX
S: A0004 OK No quota.
Its not reporting a quota.

Offline imax36581

  • Newbie
  • *
  • Posts: 9
Re: help configuring quota with dovecot
« Reply #10 on: August 07, 2012, 12:58:05 PM »
thanks for your help
but do you know how can i fix this?
i provide my dovecot configuration before, i will appreciate any help to solve this issue.

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,554
    • http://SKaero.com/
Re: help configuring quota with dovecot
« Reply #11 on: August 07, 2012, 04:17:03 PM »
I'd recommend asking on a dovecot forum since its a dovecot problem, since I have my systems setup differently.