PHP
downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

imap_listmailbox> <imap_last_error
Last updated: Fri, 30 Jan 2009

view this page in

imap_list

(PHP 4, PHP 5)

imap_listメールボックスのリストを読み込む

説明

array imap_list ( resource $imap_stream , string $ref , string $pattern )

メールボックスのリストを読み込みます。

パラメータ

imap_stream

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

ref

通常、refimap_open() で述べられているサーバ定義です。

pattern

検索を開始するメールボックスの階層を指定します。

pattern の中で使用できる特別な文字として '*' および '%' があります。'*' は、全てのメールボックスを意味します。 pattern に '*' を指定した場合、メールボックス 階層全体のリストが得られます。'%' は現在のレベルのみを意味します。 '%' を pattern に指定した場合、 トップレベルのメールボックスのみが返されます。UW_IMAPD を使用した場合、 '~/mail/%' は ~/mail ディレクトリの全てのメールボックスを返しますが、 そのディレクトリのサブフォルダーにあるメールボックスは返しません。

返り値

メールボックスの名前を含む配列を返します。

例1 imap_list() の例

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

$list imap_list($mbox"{imap.example.org}""*");
if (
is_array($list)) {
    foreach (
$list as $val) {
        echo 
imap_utf7_decode($val) . "\n";
    }
} else {
    echo 
"imap_list が失敗しました: " imap_last_error() . "\n";
}

imap_close($mbox);
?>

参考

  • imap_getmailboxes() - メールボックスのリストを読み込み、各ボックスに関する詳細な情報を返す
  • imap_lsub() - 購読しているすべてのメールボックスの一覧を得る



add a note add a note User Contributed Notes
imap_list
c6h1206free at gmail dot com
16-Sep-2008 10:00
imap_list returns a simple array of strings that look just like the $ref parameter one needs to specify:

<?php

  $srv
= '{imap.example.com}';

 
$conn = imap_open($srv, 'me', 'mypass');

 
$boxes = imap_list($conn, $srv, '*');

 
print_r($boxes);
 
imap_close($conn);
?>

Output:

<pre>
Array
(
    [0] => {imap.example.com}Calendar
    [1] => {imap.example.com}Contacts
    [2] => {imap.example.com}Deleted Items
    [3] => {imap.example.com}Drafts
    [4] => {imap.example.com}Journal
    [5] => {imap.example.com}Junk E-mail
    [6] => {imap.example.com}Notes
    [7] => {imap.example.com}Outbox
    [8] => {imap.example.com}RSS Feeds
    [9] => {imap.example.com}Sent Items 
    [10] => {imap.example.com}Tasks
)
</pre>

These directly fill in the $ref argument for every function that takes one.
kevin at metalaxe dot com
05-Jun-2007 12:13
if there is an error imap_list returns FALSE not an empty array (as expected by docs)

imap_listmailbox> <imap_last_error
Last updated: Fri, 30 Jan 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites