function MailhandlerPhpImapRetrieve::get_unread_messages in Mailhandler 6.2
Same name and namespace in other branches
- 7.2 modules/mailhandler_php_imap/plugins/mailhandler/retrieve/MailhandlerPhpImapRetrieve.class.php \MailhandlerPhpImapRetrieve::get_unread_messages()
Obtain the number of unread messages for an imap stream
Parameters
$result: IMAP stream - as opened by imap_open
object $mailbox: The mailbox to retrieve from.
Return value
array IMAP message numbers of unread messages.
1 call to MailhandlerPhpImapRetrieve::get_unread_messages()
- MailhandlerPhpImapRetrieve::retrieve in modules/
mailhandler_php_imap/ plugins/ mailhandler/ retrieve/ MailhandlerPhpImapRetrieve.class.php - Connect to mailbox and run message retrieval.
File
- modules/
mailhandler_php_imap/ plugins/ mailhandler/ retrieve/ MailhandlerPhpImapRetrieve.class.php, line 329 - Definition of MailhandlerPhpImapRetrieve class.
Class
- MailhandlerPhpImapRetrieve
- Retrieve messages using PHP IMAP library.
Code
function get_unread_messages($result, $mailbox) {
$unread_messages = array();
$number_of_messages = imap_num_msg($result);
for ($i = 1; $i <= $number_of_messages; $i++) {
$header = imap_header($result, $i);
if ($header->Unseen == 'U' || $header->Recent == 'N') {
$unread_messages[] = $i;
}
}
return $unread_messages;
}