[imp] Courier IMAP and Quota Display... Again

Craig subs at 0305.sitnominedigna.com
Sun May 25 07:58:24 PDT 2003


Hi there,

I know that there are several messages in the archives on the topic of 
getting the quota display working in IMP, but I'm still stumped after 
following all of the good advice in there. In particular I thought I had 
found the answer when I found the thread at 
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&th=ad346bf05e7fa7ff&rnum=3 
. However, that sent me on a fruitless all-night search to find out how to 
enable quota capability in Courier, as it would seem from Courier's 
response to my manual log in that it doesn't have quotas enabled:

* OK Courier-IMAP ready. Copyright 1998-2002 Double Precision, Inc.  See 
COPYING for distribution information.
1 capability
* CAPABILITY IMAP4rev1 CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT 
THREAD=REFERENCES SORT
1 OK CAPABILITY completed

(Note the lack of "QUOTA" in the response that Michael Bellears referred to 
in the post I linked to above.)

Then I followed Joshua Warchol's advice later in the thread:

telnet localhost 143
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
* OK Courier-IMAP ready. Copyright 1998-2002 Double Precision, Inc.  See 
COPYING for distribution information.
. login test at domain.tld password
. OK LOGIN Ok.
. GETQUOTA ROOT
* QUOTA "ROOT" (STORAGE 4378 4883)
. OK GETQUOTA Ok.
. logout
* BYE Courier-IMAP server shutting down
. OK LOGOUT completed
Connection closed by foreign host.

The numbers seem a little odd, but they are about right for an e-mail 
account with a 5 MB quota that is almost full. So does that mean that 
Courier actually does have quotas enabled? Beats me.

Joshua mentiones the "maildirsize" in the "user/Maildir" directory. It is 
there and looks like this:

5000000S
0 0
2911647 1
947 1
964 1
1567306 1
      571    1
1279 1

Well, actually, it *was* there -- someone in another message suggested 
deleting it because doing so fixed their problem. Apparently the MTA (qmail 
in my case) or Courier is supposed to recreate it, but I'm still waiting. 
Either way, the presence or absence of the file does not seem to make a 
difference.

Other pertinent (I hope) information:

OS: Red Hat Linux 7.3
IMAP: Courier 1.5.3-1
Horde:
IMP: 3.1
MTA: qmail with Maildir delivery


horde/imp/config/conf.php

// If this is set to a function name, that function will be used
// to show the user's quota usage on the mailbox page.
// See the 'imp_show_quota' function below for an example.
$conf['hooks']['quota'] = 'imp_show_quota';

/* Gets the quota usage from the imap server. $imap_admin &
  * $imap_passwd must be set to fit your own settings. This works
  * with the Cyrus imap server and the Courier imap server > 1.3.12.
  * Note the necessary changes for the Courier server in the comments.
  */
if (!function_exists('imp_show_quota')) {
    function imp_show_quota ($imp) {
         $quota_html = '';
//         $imap_admin = 'admin';
//         $imap_passwd = 'password';
//         // Use the following two lines instead for Courier.
         $imap_admin = $imp['user'];
         $imap_passwd = Secret::read(Secret::getKey('imp'), $imp['pass']);

         $stream = @imap_open(IMP::serverString(), $imap_admin, 
$imap_passwd, OP_HALFOPEN);
//         $quota = @imap_get_quota($stream, 'user.' . $imp['user']);
//         // Use the following line instead for Courier.
         $quota = @imap_get_quota($stream, 'ROOT');
         imap_close($stream);

         if (!empty($quota)) {
             $taken   = $quota['usage'] / 1024.0;
             $total   = $quota['limit'] / 1024.0;
             $percent = $taken * 100 / $total;
             if ($percent >= 90) {
                 $class = 'quotaalert';
             } elseif ($percent >= 75) {
                 $class = 'quotawarn';
             } else {
                 $class = 'control';
             }

             $quota_html = '<table width="100%" border="0" cellpadding="0" 
cellspacing="0"><tr><td class="item">'
                           . '<table border="0" cellspacing="2" 
cellpadding="2" width="100%"><tr><td align="center" class="' . $class . '">'
                           . sprintf("%.2fMB / %.2fMB  (%.2f%%)", $taken, 
$total, $percent)
                           . '</td></tr></table></td></tr></table>';
         }
         return $quota_html;
     }
}


Any suggestions about what I might need to do to get the quota display 
working would be very much appreciated. Thanks.


Craig



More information about the imp mailing list