Reputation: 1012
I'm using Zend_Mail_Storage_Imap to get mails from my account, the function works fine but.. How can I limit the results to show and prepare it for pagination?
$mail = new Zend_Mail_Storage_Imap(array('host' => 'example.com',
'user' => 'test',
'password' => 'test'));
foreach ($mail as $message) {
echo "Mail from '{$message->from}': {$message->subject}\n";
}
Upvotes: 2
Views: 233
Reputation: 127
Pagination with the Zend_Mail_Storage classes is straight forward. They all implement iterator interfaces and can be combined with a LimitIterator for pagination. The only gotcha is that they start with 1 instead of 0, because that's what all mail interfaces do.
$mail = new Zend_Mail_Storage_Imap(array('host' => localhost,
'user' => 'test',
'password' => 'secret'));
$mail = new LimitIterator($mail, 1, 50);
print_r(iterator_to_array($mail));
Upvotes: 2