问题
Is there any way to search messages on IMAP server, using imap_search function. According to php manual, imap_search allow only limited number of search option, and search by UID is not between them: http://us.php.net/manual/en/function.imap-search.php
So, is there a way around, to get messages based on UID(higher then provided UID). This should be supported since IMAP4 protocol revision(i think since year 2003).
回答1:
I am sure you have gone thru an extensive search and finally landed here. Lets face it, its not possible; but there can be workaround for the feature.
Maybe you can utilise code similar to this:
$imap_stream = imap_open($mailbox, $username, $password);
$msg_no = 1212; //lets say momentarily
while(imap_fetchheader($imap_stream, $msg_no)){
//do some processing
$msg_no++;
}// loop will continue till there is no more of newer messages
Be aware that this can cause Maximum Execution Time so you can take in a for loop to do the job with specific number of iteration.
$imap_stream = imap_open($mailbox, $username, $password);
$msg_no = 1212; //lets say
for($i=0;$i<=50;$i++){
if(imap_fetchheader($imap_stream, $msg_no)){
//do some processing
}
$msg_no++;
} // this will go for 50 times
来源:https://stackoverflow.com/questions/10173041/php-imap-search-based-on-message-uid