Reputation: 2346
I am using Zend framework to fetch email messages from Gmail, Currently I am only able to get messages in INBOX only, After Authentication i setToken and other parameters
$imap->requestAndResponse('AUTHENTICATE', $authenticateParams);
$response = $imap->requestAndResponse('XLIST', $imap->escapeString('', '*'));
in the $responce Variable i am getting list of all my Labels/folders
Array
(
[0] => Array
(
[0] => XLIST
[1] => Array
(
[0] => \HasNoChildren
)
[2] => /
[3] => Calendar
).................... INBOX, Sent Mails Etc
and so on, After doing some code and fetching Names on Index [3] Which are my Labels and Folders.
i Have list in array like below.
Array
(
[0] => Calendar
[1] => Drafts
[2] => Facebook Mails
[3] => Inbox
[4] => Junk E-mail
[5] => Logs
[6] => Personal Mails
[7] => Sent Items
[8] => Office Mails
)
Now i want to fetch emails in each message/folders
I tried Zend_Mail_Storage_Folder_Maildir
but i do not Know exactly how to fetch messages in each of the above folder, I am using Imap,
By Opening Storage like below
$storage = new Zend_Mail_Storage_Imap($imap);
This only returns mails in Inbox Folder.
Upvotes: 2
Views: 1648
Reputation: 1493
To Display All folders
$storage = new Zend_Mail_Storage_Imap($this->imap);
$folders = new RecursiveIteratorIterator($storage->getFolders(), RecursiveIteratorIterator::SELF_FIRST);
echo '<select name="folder">';
foreach ($folders as $localName => $folder) {
$localName = str_pad('', $folders->getDepth(), '-', STR_PAD_LEFT) .
$localName;
echo '<option';
if (!$folder->isSelectable()) {
echo ' disabled="disabled"';
}
echo ' value="' . htmlspecialchars($folder) . '">'
. htmlspecialchars($localName) . '</option>';
}
echo '</select>';
To Select a Folder
$storage->selectFolder("[Gmail]/Sent Mail");
[Gmail]/Sent Mail label for select sent mail folder
Upvotes: 2