1

Topic: Problem configuring Store.Realtime.Quota.In.MySQL

My setup is iRedMail-0.6.1 on a CentOS 5.4 machine.

  I followed the "Upgrade.Dovecot.1.1.to.1.2" tutorial and successfully upgraded to Dovecot 1.2.  Since I wanted to store quota in mysql, followed ZhangHuangbin's tutorial  "Store.Realtime.Quota.In.MySQL" word for word and restarted dovecot & postfix services.

When I try to send a mail it spits out the following error in "sieve.log"

Oct 19 16:22:57 deliver(postmaster@example.com): Error: Internal quota calculation error
Oct 19 16:22:57 deliver(postmaster@example.com): Error: sieve: msgid=<a26d4bab4636c621c786ac39a32ba1c5@example.com>: failed to store into mailbox 'INBOX': Internal error occurred. Refer to server log for more information. [2010-10-19 16:22:57]
Oct 19 16:22:57 deliver(postmaster@example.com): Error: sieve: script /var/vmail/sieve/example.com/postmaster/dovecot.sieve failed with unsuccessful implicit keep

[root@mail ~]# mailq
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
AFC4C3901EA     1594 Tue Oct 19 16:14:34  falcon@example.com
                                                           (temporary failure)
                                         postmaster@example.com
                                         raptor@example.com

-- 2 Kbytes in 1 Request.


  Can anyone please tell me why this is happening and how to solve this.

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Problem configuring Store.Realtime.Quota.In.MySQL

Any log in /var/log/dovecot.log?
Also, can you set "mail_debug = yes" in dovecot.conf, send one more testing email, and post related log here? both /var/log/dovecot.log, and sieve.log.

3

Re: Problem configuring Store.Realtime.Quota.In.MySQL

/etc/dovecot-used-quota.conf

# used password for vmailadmin in iRedMail.tips file #
connect = host=localhost dbname=vmail user=vmailadmin password=r21JQMc59LNkVNmvAjvjKbLBdSzY8E
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
}

dovecot.log with "mail_debug=yes" enabled

Oct 19 19:19:26 IMAP(falcon@example.com): Info: Loading modules from directory: /usr/lib/dovecot/imap
Oct 19 19:19:26 IMAP(falcon@example.com): Info: Module loaded: /usr/lib/dovecot/imap/lib10_quota_plugin.so
Oct 19 19:19:26 IMAP(falcon@example.com): Info: Module loaded: /usr/lib/dovecot/imap/lib11_imap_quota_plugin.so
Oct 19 19:19:26 IMAP(falcon@example.com): Info: Effective uid=501, gid=501, home=/var/vmail/vmail1/example.com/falcon/
Oct 19 19:19:26 IMAP(falcon@example.com): Info: Quota root: name=user backend=dict args=:proxy::quotadict
Oct 19 19:19:26 IMAP(falcon@example.com): Info: Quota rule: root=user mailbox=* bytes=10485760 messages=0
Oct 19 19:19:26 IMAP(falcon@example.com): Info: Quota warning: bytes=8912896 (85%) messages=0 command=/usr/local/bin/dovecot-quota-warning.sh 85
Oct 19 19:19:26 IMAP(falcon@example.com): Info: Quota warning: bytes=9437184 (90%) messages=0 command=/usr/local/bin/dovecot-quota-warning.sh 90
Oct 19 19:19:26 IMAP(falcon@example.com): Info: Quota warning: bytes=9961472 (95%) messages=0 command=/usr/local/bin/dovecot-quota-warning.sh 95
Oct 19 19:19:26 IMAP(falcon@example.com): Info: dict quota: user=falcon@example.com, uri=proxy::quotadict, noenforcing=0
Oct 19 19:19:26 IMAP(falcon@example.com): Info: maildir: data=//var/vmail/vmail1/example.com/falcon//Maildir/:INDEX=//var/vmail/vmail1/example.com/falcon//Maildir/
Oct 19 19:19:26 IMAP(falcon@example.com): Info: maildir++: root=//var/vmail/vmail1/example.com/falcon//Maildir, index=, control=, inbox=//var/vmail/vmail1/example.com/falcon//Maildir
Oct 19 19:19:26 imap-login: Info: Login: user=<falcon@example.com>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, secured
Oct 19 19:19:26 IMAP(falcon@example.com): Info: Namespace : Using permissions from //var/vmail/vmail1/example.com/falcon//Maildir: mode=0700 gid=-1
Oct 19 19:19:26 IMAP(falcon@example.com): Info: Disconnected: Logged out bytes=274/2503

corresponding "sieve.log" file

Oct 19 19:16:26 deliver(raptor@example.com): Info: Loading modules from directory: /usr/lib/dovecot/lda
Oct 19 19:16:26 deliver(raptor@example.com): Info: Module loaded: /usr/lib/dovecot/lda/lib10_quota_plugin.so
Oct 19 19:16:26 deliver(raptor@example.com): Info: Module loaded: /usr/lib/dovecot/lda/lib90_sieve_plugin.so
Oct 19 19:16:26 deliver(raptor@example.com): Info: auth input: home=/var/vmail/vmail1/example.com/raptor/
Oct 19 19:16:26 deliver(raptor@example.com): Info: auth input: quota_rule=*:bytes=10485760
Oct 19 19:16:26 deliver(raptor@example.com): Info: Quota root: name=user backend=dict args=:proxy::quotadict
Oct 19 19:16:26 deliver(raptor@example.com): Info: Quota rule: root=user mailbox=* bytes=10485760 messages=0
Oct 19 19:16:26 deliver(raptor@example.com): Info: Quota warning: bytes=8912896 (85%) messages=0 command=/usr/local/bin/dovecot-quota-warning.sh 85
Oct 19 19:16:26 deliver(raptor@example.com): Info: Quota warning: bytes=9437184 (90%) messages=0 command=/usr/local/bin/dovecot-quota-warning.sh 90
Oct 19 19:16:26 deliver(raptor@example.com): Info: Quota warning: bytes=9961472 (95%) messages=0 command=/usr/local/bin/dovecot-quota-warning.sh 95
Oct 19 19:16:26 deliver(raptor@example.com): Info: dict quota: user=raptor@example.com, uri=proxy::quotadict, noenforcing=0
Oct 19 19:16:26 deliver(raptor@example.com): Info: maildir: data=//var/vmail/vmail1/example.com/raptor//Maildir/:INDEX=//var/vmail/vmail1/example.com/raptor//Maildir/
Oct 19 19:16:26 deliver(raptor@example.com): Info: maildir++: root=//var/vmail/vmail1/example.com/raptor//Maildir, index=, control=, inbox=//var/vmail/vmail1/example.com/raptor//Maildir
Oct 19 19:16:26 deliver(raptor@example.com): Info: dict quota: user=raptor@example.com, uri=proxy::quotadict, noenforcing=0
Oct 19 19:16:26 deliver(raptor@example.com): Info: sieve: user's script path /var/vmail/sieve/example.com/raptor/dovecot.sieve doesn't exist (using global script path in stead)
Oct 19 19:16:26 deliver(raptor@example.com): Info: sieve: using sieve path for user's script: /var/vmail/sieve/dovecot.sieve
Oct 19 19:16:26 deliver(raptor@example.com): Info: sieve: opening script /var/vmail/sieve/dovecot.sieve
Oct 19 19:16:26 deliver(raptor@example.com): Info: sieve: executing compiled script /var/vmail/sieve/dovecot.sieve
Oct 19 19:16:27 deliver(raptor@example.com): Info: Namespace : Using permissions from //var/vmail/vmail1/example.com/raptor//Maildir: mode=0700 gid=-1
Oct 19 19:16:27 deliver(raptor@example.com): Error: Internal quota calculation error
Oct 19 19:16:27 deliver(raptor@example.com): Error: sieve: msgid=<eecba1af73ccf2527444c557010baec7@example.com>: failed to store into mailbox 'INBOX': Internal error occurred. Refer to server log for more information. [2010-10-19 19:16:26]
Oct 19 19:16:27 deliver(raptor@example.com): Error: sieve: script /var/vmail/sieve/dovecot.sieve failed with unsuccessful implicit keep

4

Re: Problem configuring Store.Realtime.Quota.In.MySQL

Can you post output of command 'dovecot -n'?

5

Re: Problem configuring Store.Realtime.Quota.In.MySQL

[root@mail ~]# dovecot -n
# 1.2.14: /etc/dovecot.conf
# OS: Linux 2.6.18-164.el5 i686 CentOS release 5.4 (Final)
log_path: /var/log/dovecot.log
protocols: imap imaps managesieve
listen(default): *
listen(imap): *
listen(managesieve): 127.0.0.1:2000
ssl_cert_file: /etc/pki/tls/certs/iRedMail_CA.pem
ssl_key_file: /etc/pki/tls/private/iRedMail.key
login_dir: /var/run/dovecot/login
login_executable(default): /usr/libexec/dovecot/imap-login
login_executable(imap): /usr/libexec/dovecot/imap-login
login_executable(managesieve): /usr/libexec/dovecot/managesieve-login
mail_uid: 501
mail_gid: 501
mail_location: maildir:/%Lh/Maildir/:INDEX=/%Lh/Maildir/
mail_debug: yes
mail_executable(default): /usr/libexec/dovecot/imap
mail_executable(imap): /usr/libexec/dovecot/imap
mail_executable(managesieve): /usr/libexec/dovecot/managesieve
mail_plugins(default): quota imap_quota
mail_plugins(imap): quota imap_quota
mail_plugins(managesieve):
mail_plugin_dir(default): /usr/lib/dovecot/imap
mail_plugin_dir(imap): /usr/lib/dovecot/imap
mail_plugin_dir(managesieve): /usr/lib/dovecot/managesieve
lda:
  postmaster_address: root
  auth_socket_path: /var/run/dovecot/auth-master
  mail_plugins: sieve quota
  sieve_global_path: /var/vmail/sieve/dovecot.sieve
  log_path: /var/log/sieve.log
auth default:
  mechanisms: plain login
  default_realm: example.com
  user: vmail
  passdb:
    driver: sql
    args: /etc/dovecot-mysql.conf
  userdb:
    driver: sql
    args: /etc/dovecot-mysql.conf
  socket:
    type: listen
    client:
      path: /var/spool/postfix/dovecot-auth
      mode: 438
      user: postfix
      group: postfix
    master:
      path: /var/run/dovecot/auth-master
      mode: 438
      user: vmail
      group: vmail
plugin:
  quota_warning: storage=85%% /usr/local/bin/dovecot-quota-warning.sh 85
  quota_warning2: storage=90%% /usr/local/bin/dovecot-quota-warning.sh 90
  quota_warning3: storage=95%% /usr/local/bin/dovecot-quota-warning.sh 95
  quota: dict:user::proxy::quotadict
  quota_rule: *:storage=100M
  expire: Trash 7 Trash/* 7 Junk 30
  expire_dict: proxy::expire
  auth_socket_path: /var/run/dovecot/auth-master
  sieve: /var/vmail/sieve/%Ld/%Ln/dovecot.sieve
  sieve_dir: /var/vmail/sieve/%Ld/%Ln/
dict:
  quotadict: mysql:/etc/dovecot-used-quota.conf
  expire: db:/var/lib/dovecot/expire/expire.db

6

Re: Problem configuring Store.Realtime.Quota.In.MySQL

Config is correct.

quote from @maxie_ro's post (http://www.iredmail.org/forum/topic1306-enh-mysqlbased-used-quota.html ):

The table entries will get updated only when an user receives or deletes a message. So it might take some time for the table to fill up. You might get some oddities in the mean time (including negative usage quota).

I guess you're in same situation.

7

Re: Problem configuring Store.Realtime.Quota.In.MySQL

Thanks for your rapid responses, I also referred maxie_ro's tutorial during the whole time.

But my problem is the mail is not getting delivered at all

"/var/log/maillog"

Oct 19 10:19:00 mail postfix/pipe[3781]: 1A3023901EB: to=<raptor@example.com>, relay=dovecot, delay=251, delays=251/0.05/0/0.05, dsn=4.3.0, status=deferred (temporary failure)

[root@mail ~]# mailq
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
AFC4C3901EA     1594 Tue Oct 19 16:14:34  falcon@example.com
                                                           (temporary failure)
                                         postmaster@example.com
                                         raptor@example.com

-- 2 Kbytes in 1 Request.

After solving this only we can get to the next step i.e worrying about quota.

"The table entries will get updated only when an user receives or deletes a message. So it might take some time for the table to fill up. You might get some oddities in the mean time (including negative usage quota)."

However if I revert back to old plugin "Maildir" everything works fine.

8

Re: Problem configuring Store.Realtime.Quota.In.MySQL

"Maildir" format stores quota in file "maildirsize" under each mailbox. Try to delete this file in your testing account and test it again. Don't worry, 'maildirsize' will be created automatically if it's missing.