Search code examples
phpoffice365imap

PHP imap_list() shows only INBOX and no other folders


When running the PHP code below I get only one folder, the INBOX.

<?php
$server = '{outlook.office365.com:995/pop3/ssl/novalidate-cert}';
$connection = imap_open($server, '[email protected]', 'XXXXX');
$mailboxes = imap_list($connection, $server, '*');
var_dump($mailboxes);
?>

Ouput:

array(1) { [0]=> string(57) "{outlook.office365.com:995/pop3/ssl/novalidate- cert}INBOX" }

While there do exist multiple standard and custom folders. In fact, I want to move emails from the INBOX to the trash folder. But I can not even find the correct name of the trash folder.


Solution

  • Folders are not available in the POP3 protocol. You must connect using IMAP.