imap_get_quota

(PHP 4 >= 4.0.5, PHP 5, PHP 7, PHP 8)

imap_get_quotaクオータレベルの設定、メールボックス毎の使用状況を取得する

説明

imap_get_quota(resource $imap, string $quota_root): array|false

クオータレベルの設定、メールボックス毎の使用状況を取得します。

この関数の非管理者向けバージョンは、 PHP の imap_get_quotaroot() 関数を参照ください。

パラメータ

imap

imap_open() が返す IMAP ストリーム。

quota_root

quota_root は、通常 user.name という形式にする必要があります。 name は、情報を取得したいメールボックスの名前です。

返り値

指定したメールボックスの limit と usage をキーとした整数値を配列として返します。 limit の値は、このメールボックスで最大使用可能な大きさを表します。 usage の値は、このメールボックスの現在の使用状況を示します。 失敗した場合に false を返します。

PHP 4.3 では、この関数は » RFC2087 で述べられている機能をより適切に反映するようになっています。 返り値の配列からは、サポートするリソース (例:メッセージ、あるいはサブフォルダ)数の制限をなくし、 名前つきリソースを独立した配列のキーとして受信するようにしました。 各キーの値は配列となっており、その中に usage と values の値が格納されています。

過去との互換性を保つため、旧来のアクセス方法も使用可能です。 しかし新しい方法に変更することを推奨します。

例1 imap_get_quota() の例

<?php
$mbox 
imap_open("{imap.example.org}""mailadmin""password"OP_HALFOPEN)
      or die(
"接続できません: " imap_last_error());

$quota_value imap_get_quota($mbox"user.kalowsky");
if (
is_array($quota_value)) {
    echo 
"Usage level is: " $quota_value['usage'];
    echo 
"Limit level is: " $quota_value['limit'];
}

imap_close($mbox);
?>

例2 4.3 以降のバージョンでの imap_get_quota() の例

<?php
$mbox 
imap_open("{imap.example.org}""mailadmin""password"OP_HALFOPEN)
      or die(
"接続できません: " imap_last_error());

$quota_values imap_get_quota($mbox"user.kalowsky");
if (
is_array($quota_values)) {
   
$storage $quota_values['STORAGE'];
   echo 
"STORAGE usage level is: " .  $storage['usage'];
   echo 
"STORAGE limit level is: " .  $storage['limit'];

   
$message $quota_values['MESSAGE'];
   echo 
"MESSAGE usage level is: " .  $message['usage'];
   echo 
"MESSAGE limit is: " .  $message['limit'];

   
/* ...  */
}

imap_close($mbox);
?>

注意

この関数は、現在、c-client2000 以降のライブラリを使用しているユーザーのみ使用可能です。

指定する imap は、 メールの管理者としてオープンしたものである必要があります。 そうでない場合は、この関数は失敗します。

参考

  • imap_open() - メールボックスへの IMAP ストリームをオープンする
  • imap_set_quota() - 指定したメールボックスにクォータを設定する
  • imap_get_quotaroot() - ユーザー単位のクォータ設定を取得する

add a note add a note

User Contributed Notes 3 notes

up
1
Anti Veeranna
17 years ago
If you're using this (or probably any other imap functions) and getting "Notice: Unknown: Quota root does not exist (errflg=2) in Unknown on line 0" errors after the script finishes, then call imap_errors() function before you close the imap stream - this will clear the error stack and you don't get those annoying notices.

Took me a while to figure it out.
up
0
Shiraz Esat
19 years ago
For this function to work your IMAP server must also have the 'getquota' capability!

Check this by logging in directly:
telnet <mail server> <port>

e.g. telnet mail.myserver.com 143

and then once you're connected to the server
0 CAPABILITY
up
-1
dc at aufruhr dot com
20 years ago
ok, this error just occurs if there are no quotas on your mailbox.

same with imap_get_quotaroot().
To Top