Php imap_list injecting crap in my output

Hi
I want to return a CLEAN list of my folders but imap_list reqiures three parameter the second of which goes in to my output. imap_list ( resource $imap_stream , string $ref , string $pattern ).
Why is this??? Here is my code:

<?php

$mailbox = "mail.e17pumphouse.org.uk";
$username = "enquiries@e17pumphouse.org.uk";
$password = "password";
$encryption = "notls"; // or ImapClient::ENCRYPT_SSL or ImapClient::ENCRYPT_TLS or null

$mbox = imap_open("{".$mailbox."/".$encryption."}", $username, $password);

echo "<h1>Mailboxes</h1>\n";
$folders = imap_listmailbox($mbox, "{".$mailbox."/".$encryption."}", "*");

if ($folders == false) {
    echo "Call failed<br />\n";
} else {
    foreach ($folders as $val) {
        echo $val . "<br />\n";
    }
}

imap_close($mbox);
?>

This outputs:

{mail.e17pumphouse.org.uk/notls}Sent
{mail.e17pumphouse.org.uk/notls}Spam
{mail.e17pumphouse.org.uk/notls}Trash
{mail.e17pumphouse.org.uk/notls}Drafts
{mail.e17pumphouse.org.uk/notls}INBOX

It should be:

Sent
Spam
Trash
Drafts
INBOX

Thanks in advance.

According to a note on the documentation, the information in the array is sufficient to use as the $ref parameter in any of the other imap functions that require that parameter. Can’t you just strip it out before you display it?

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.