function mailhandler_get_unread_messages in Mailhandler 7
Same name and namespace in other branches
- 6 mailhandler.retrieve.inc \mailhandler_get_unread_messages()
Obtain the number of unread messages for an imap stream
Parameters
$result: IMAP stream - as opened by imap_open
Return value
Array, values contain message numbers
1 call to mailhandler_get_unread_messages()
- mailhandler_retrieve in ./
mailhandler.retrieve.inc - Connect to mailbox and run message retrieval
File
- ./
mailhandler.retrieve.inc, line 336
Code
function mailhandler_get_unread_messages($result) {
$unread_messages = array();
$number_of_messages = imap_num_msg($result);
for ($i = 1; $i <= $number_of_messages; $i++) {
$header = imap_header($result, $i);
// only process new messages
if ($header->Unseen != 'U' && $header->Recent != 'N') {
continue;
}
$unread_messages[] = imap_uid($result, $i);
}
return $unread_messages;
}