IMAP: How to list an INBOX's sub folders

stuffer
stuffer used Ask the Experts™
on
I have a problem accessing the folders I have created within my INBOX.

At present I have created a numebr of subfolders within my mail box. When I then access the mailbox using the imap functions I can only return the messages stored in the root folder. i.e.

   INBOX
      |
      |- SPAM
      |
      L INFO

I can access all information stored in the root of INBOX but not see or access any messages stored in SPAM or INFO.

I am using the following code:-

<?php

      $mbox = imap_open ("{SERVER:110/pop3}", "MyUserName", "MyPassWord") or die("can't connect: ".imap_last_error());
      
      $list = imap_list($mbox,"{SERVER:110/pop3}","*");
      if(is_array($list))
      {
            reset($list);
            while (list($key, $val) = each($list))
            {
                  print imap_utf7_decode($val)."<br>\n";
            }
      }
      else
            print "imap_list failed: ".imap_last_error()."\n";
      
      $BoxList = imap_getmailboxes($mbox,"{SERVER:110/pop3}","*");
      print_r($BoxList);
      while (list($key, $val) = each($BoxList))
      {
            print "($key) ";
            print imap_utf7_decode($val->name).",";
            print "'".$val->delimiter."',";
            print $val->attributes."<br>\n";
      }       
      imap_close($mbox);
?>

I am using these functions on POP3 and have found that some of the functions dont work as they were written for IMAP. Yet can someone please confirm that either I cant do this or help me out in some way??
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Judging from the remarks on the php site, there are some inconsistencies with POP protocol compared to IMAP.  Have you tried connecting to your server via IMAP?  If you can use an IMAP server that would be the easiest thing.  I can't even find a POP server to test on, all mine are IMAP :P

Try this, though.  It should show the contents of your INFO mailbox:

$list = imap_list($mbox,"{SERVER:110/pop3}","INFO/*");

Author

Commented:
Nope afraid not, nothing is returned again. I will have a word with our Network Admin guy and see if he can convert the mailbox to IMAP.

Cheers for the comment though Shmert.

Author

Commented:
I have managed to convert the mailboxes to IMAP and had a problem still accessing the mailbox yet found the fault to be the connection details. I still tried connecting on port 110 when IMAP runs over port 143.

Thanks Shmert

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial