Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[imp] Courier IMAP and 'imp_show_quota'/today's HEAD Version.

3 views
Skip to first unread message

Edwin Culp

unread,
Jun 4, 2002, 9:50:12 PM6/4/02
to
Seeing so many folks with quotas working, I became envious and decided
to give it a try on my courier imap/Imp test machine. I set up cuotas,
tested it by telneting into the machine. Telnet worked fine. I eagerly
logged in expecting to see my quota, but in place of the quota I got
the following:

Warning: imap_close(): supplied argument is not a valid imap resource in
/usr/src/horde/imp/config/conf.php on line 426

It doesn't seem to like the imap_close(). I have not made any changes to
the sample in conf.php which is very, very similar to the example in the
imap_get_quota() example in the php manual.

$stream = @imap_open(IMP::serverString(), $imap_admin, $imap_passwd,
OP_HALFOPEN);
$quota = @imap_get_quota($stream, 'ROOT');
imap_close($stream);

What could I be missing here?

Thanks for your help or suggestions.

ed
--


-------------------------------------------------------------
http://insourcery.com - Mergence of Business and Technology
a "Griffin Plaza Partners, LLC" Company

--
IMP mailing list
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: imp-uns...@lists.horde.org

Edwin Culp

unread,
Jun 5, 2002, 2:13:41 AM6/5/02
to
I fixed the prevous problems and now get no errors but no quota although
it works manually and the maildirsize file has been created with the proper
values. Somehow I'm not reading the quota. I'm recompiling cclient right
now.

Thanks,

ed

Quoting Edwin Culp <ec...@encontacto.net>:

| Seeing so many folks with quotas working, I became envious and decided
| to give it a try on my courier imap/Imp test machine. I set up cuotas,
| tested it by telneting into the machine. Telnet worked fine. I eagerly
| logged in expecting to see my quota, but in place of the quota I got
| the following:
|
| Warning: imap_close(): supplied argument is not a valid imap resource in
| /usr/src/horde/imp/config/conf.php on line 426
|
| It doesn't seem to like the imap_close(). I have not made any changes to
| the sample in conf.php which is very, very similar to the example in the
| imap_get_quota() example in the php manual.
|
| $stream = @imap_open(IMP::serverString(), $imap_admin, $imap_passwd,
| OP_HALFOPEN);
| $quota = @imap_get_quota($stream, 'ROOT');
| imap_close($stream);

Edwin Culp

unread,
Jun 5, 2002, 2:31:29 AM6/5/02
to
Quoting Edwin Culp <ec...@encontacto.net>:

| I fixed the prevous problems and now get no errors but no quota although
| it works manually and the maildirsize file has been created with the proper
| values. Somehow I'm not reading the quota. I'm recompiling cclient right
| now.

I recompiled and reinstalled
imap-uw-2001a,1
cclient-2001a,1
mod_php4-4.2.1
restarted apache and still no quota. I don't seem to be getting anything
our of courier.

ed

|
| Thanks,
|
| ed

Tjeerd van der Zee

unread,
Jun 5, 2002, 6:22:08 AM6/5/02
to
Hi,

I've modified the quota script for use with courier imap and ldap.

the only thing this is being done with ldap is retreive the homedir from
ldap.
you change that with the function in the original script.

I've had some troubles also with quota functions of courier imap.

You need to compile courier imap with

--enable-workarounds-for-imap-client-bugs

otherwise c-client will fail to retreive the quota for a user.

The passwords is retreived from Horde, but if you wan't, you could also get
it from ldap since the user is known.

The user gets his quota with his own username and password.

It searches for the maildirsize file in the homedir, when it isn't present,
it just skips
the quotabar creation.

With kind regards,

Tjeerd van der Zee.

if (!function_exists('imp_show_quota')) {
function imp_show_quota ($imp) {

$imapuser = $imp['user'];
$splitted = split("@", $imapuser);
$realname = @$splitted[0]; $realm = @$splitted[1];
$imapadminpass = Auth::getCredential('password');
$imaphost = '{localhost:143}';

$quota_html = '<table width="100%" border="0" cellpadding="0"
cellspacing="0"><tr><td class="item"><table border="0" cellspacing="0"
cellpadding="0" width="100%"><tr>';
$quota_html .= '<td align="left" class="header">Login: ' . $realname . "
(" . $imapuser . ")" . '</td>';

$ds=ldap_connect("localhost");
if ($ds) {
$r=ldap_bind($ds);
$sr=ldap_search($ds,"o=xar.nl", "mail=$imapuser");
$info = ldap_get_entries($ds, $sr);
for ($i=0; $i<$info["count"]; $i++) {
@$homedir=$info[$i]["homedirectory"][0];
}
ldap_close($ds);
}

// check for the maildirsize file.
$homedir = $homedir . "/Maildir/maildirsize";
if(file_exists("$homedir")){

$userprefix = 'user.';
$mbox = imap_open($imaphost, $imapuser, $imapadminpass, OP_HALFOPEN) or
die ("Imap host is down");
$quota = imap_get_quota($mbox, $userprefix.$imapuser) or die ("");
imap_close($mbox);


if (is_array($quota) && $quota['limit'] != 0) {
$taken = $quota['usage'] / 1024.0;
$total = $quota['limit'] / 1024.0;
$percent = $taken * 100 / $total;
if ($percent >= 90) {
$color = '#FF0000';
} elseif ($percent >= 80) {
$color = '#FCE30D';
} else {
$color = '#339933';
}
$quota_html .= '<td align="center" class="header">';
$quota_html .= sprintf("<font size=-2>Quota on /%s: %.1fMB/%.1fMB
(%.1f%%)</font>", "Maildir", $taken, $total, $percent);
$quota_html .= '</td><td width="30" class="header"
align="right"><font size="-3">0%</font></td><td width="200"
class="header">';
$quota_html .= '<table width="100%"><tr><td
bgcolor="#ccccff"><div style="height:6px; width:'. sprintf("%.1f%%",
$percent). '; font-size:3px; background-color:'.$color.'">';
$quota_html .= '</div></td></tr></table></td><td width="30"
class="header" align="left"><font size="-3">100%</font>';
} else {
$quota_html .= '<td align="center" class="header">';
$quota_html .= "Quota not available";
}
$quota_html .= '</td></tr></table></td></tr></table>';
return $quota_html;

Edwin Culp

unread,
Jun 5, 2002, 9:50:51 AM6/5/02
to
Quoting Tjeerd van der Zee <Tjeerd...@chello.nl>:

| Hi,
|
| I've modified the quota script for use with courier imap and ldap.
|
| the only thing this is being done with ldap is retreive the homedir from
| ldap.
| you change that with the function in the original script.
|
| I've had some troubles also with quota functions of courier imap.
|
| You need to compile courier imap with
|
| --enable-workarounds-for-imap-client-bugs

Tjeerd,

Thanks for the code.

I always use that. In fact, I even built the, just released, courier
mail suite, 38.2 and with --enable-workarounds-for-imap-client-bugs
out of desperation.

I think I may have found my problem after changing to your code. I
seem to have a problem reading the maildirsize because of a permissions
issue with apache2, courier and my shared virtual user uid. I'll
fix that later after a 7am meeting and let you know. I knew I was
going to have to address it but since it hadn't bitten me . . . .:-)


Again, thanks for the help,

ed

0 new messages