imap_get_quotaroot

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

imap_get_quotarootユーザー単位のクォータ設定を取得する

説明

imap_get_quotaroot(resource $imap, string $mailbox): array|false

ユーザー単位のクォータ設定を取得します。 limit の値は、このユーザーがメールボックスで使用可能な総容量を表します。 usage の値は、ユーザーが現在メールボックスで使用している容量を表します。

パラメータ

imap

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

mailbox

mailbox はどのメールボックスを調べるかを 指定します(例: INBOX)。

返り値

指定したユーザーのメールボックスに関連する整数値を配列で返します。 すべての値にはリソース名に基づいたキーがつけられており、 usage および limit 値を保持する配列が関連付けられています。

コールが失敗した場合、およびサーバーからの応答内容をパースできなかった場合には この関数は false を返します。

例1 imap_get_quotaroot() の例

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

$quota imap_get_quotaroot($mbox"INBOX");
if (
is_array($quota)) {
   
$storage $quota['STORAGE'];
   echo 
"STORAGE usage level is: " .  $storage['usage'];
   echo 
"STORAGE limit level is: " .  $storage['limit'];

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

   
/* ...  */

}

imap_close($mbox);
?>

注意

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

imap は、 調べたいメールボックスを所有するユーザーがオープンしなければなりません。

参考

  • imap_open() - メールボックスへの IMAP ストリームをオープンする
  • imap_set_quota() - 指定したメールボックスにクォータを設定する
  • imap_get_quota() - クオータレベルの設定、メールボックス毎の使用状況を取得する

add a note add a note

User Contributed Notes 3 notes

up
6
thomas dot hebinck at digionline dot de
20 years ago
['STORAGE']['usage'] and ['STORAGE']['limit'] are values in KB (1024 Bytes)
up
3
uphonesimon at gmail dot com
18 years ago
just to make a note for all the people that are wondering the differences between $quota['STORAGE'] and $quot['MESSAGE']
the $quot['STORAGE'] is the size of the mailbox in KB
but $quota['MESSAGE'] is actually the number of messages stored in the mailbox and the up limit of the total messages allowed
up
-2
rodrigo dot tsuru at tsuru dot net
19 years ago
The example above isn't right. Replace with this:

<?php
$mbox
= imap_open("{your.imap.host}", "kalowsky", "password", OP_HALFOPEN)
     or die(
"can't connect: " . imap_last_error());

$quota = imap_get_quotaroot($mbox, "INBOX");
if (
is_array($quota)) {
  
$storage = $quota['STORAGE'];
   echo
"STORAGE usage level is: " $storage['usage'];
   echo
"STORAGE limit level is: " $storage['limit'];

  
$message = $quota['MESSAGE'];
   echo
"MESSAGE usage level is: " $message['usage'];
   echo
"MESSAGE usage level is: " $message['limit'];

  
/* ...  */

}

imap_close($mbox);
?>
To Top