Closed geri777 closed 6 years ago
Arrays start at 0 not 1. If you want to access #3 you need to request #4
I thought it is 1-based, because when I look in function checkMessageId($id) I find ... if($id > $this->countMessages()){ throw new ImapClientException('Bad message number'); }
But anyway - THIS IS NOT THE PROBLEM unfortunately. I get a very old message (maybe number 500 or so), which is not part of the $imap->getMessages(20).
Lets take for example an array with 49 messages. Count messages would return 50. But if you ask for the number 50, the exception is thrown. Get it?
On the part about the message, just grab that section
If you have 50 messages, count will return 50, wouldn't it? If you have a Null-based index the highest id can be 49. In this case the checkMessageId would be if($id >= $this->countMessages())
(note the equal sign).
Please post the part with "grab that section" again. If I click it it's empty. Many thanks!
I now understand what's going wrong. I am creating a new array in my foreach loop - with a new index. I had to use the old index IDs to access the single messages:
$allEmails = $imap->getMessages(20);
foreach($allEmails As &$email) {
// I want to get the message with "Hello" in the subject
if($email['subject'] = 'Hello' {
var_dump($imap->getMessage($email['uid']));
}
}
When I pull the last 20 messages and then want to access a specific message I get the wrong one. The message I get is not within the 20 messages of $allEmails. I am using POP3 not IMAP.