Hi
I need an alternative to $arr = imap_headers ($mbox);
My mailbox has over 10K msgs and its taking a lot of time to get the headers alone. Plus memory etc.
How do I get it like the way we can get data from a mysql table ? $msgno= get_imap_msgs($mbox) and then iterate it via its msg nos - $info = imap_headerinfo($mbox, $msgno); ?
Thanks
Getting Message headers one by one via Msg Number
Moderator: General Moderators
Code: Select all
<?php
$mbox = imap_open("{mail.domain.com:110/pop3}INBOX", "username", "password");
// $a = imap_headers ($mbox); // This I dont want !
$res = get_imap_msgs($mbox);
while ($row = get_imap_email($res)
{
echo $row['msgno'].' - '.$row['subject']."\n";
}
imap_close ($mbox);
?>I just tested with a test email address.
Sent 4 mails - all got received - msgids were 1, 2, 3 and 4.
I deleted Email 2 (in Squirrel Mail) manually and when I tried to read msgid 2 it gave Bad message number in...
So if there are 10,000 emails in a mail box how do I iterate though each header one by one ? Now after my test, obviously 1 to 10,000 wont be the right iteration - so how do I do a obj->getNextMsgId() in php ?
imap_status has something called SA_UIDNEXT called by $status->uidnext which is what I want - but says imap_status -- This function returns status information on a mailbox other than the current one - and I want for the current one !
Sent 4 mails - all got received - msgids were 1, 2, 3 and 4.
I deleted Email 2 (in Squirrel Mail) manually and when I tried to read msgid 2 it gave Bad message number in...
So if there are 10,000 emails in a mail box how do I iterate though each header one by one ? Now after my test, obviously 1 to 10,000 wont be the right iteration - so how do I do a obj->getNextMsgId() in php ?
imap_status has something called SA_UIDNEXT called by $status->uidnext which is what I want - but says imap_status -- This function returns status information on a mailbox other than the current one - and I want for the current one !