son.of.the.morning Posted August 21, 2012 Share Posted August 21, 2012 Due to the lack of speed that Imap provides i have to write some filters to avoid bringing in countless un-needed emails. I have had a little mess with the sort functions and other functions Imap has to offer but i can?t seem to drag out email in a specific order using imap_sort(). // Connection method function _connection() { $this->dir = imap_open($this->host,$this->user,$this->password); if($this->dir!=FALSE) { return 'Connection successful.'; return $this->dir; } else { return 'Connection error: '; return imap_last_error(); } } // List emails method function _readMail() { if($this->collect) { $i = 0; $mail = array(); for($i=1; $i<20; $i++) { $details = imap_fetch_overview($this->dir,$i,0); $body = imap_fetchbody($this->dir,$i,2); $status = $details[0]->seen ? 'read' : 'unread'; $from = $details[0]->from; $date = $details[0]->date; if(isset($details[0]->subject)) $subject = $details[0]->subject ; else $subject = 'no subject'; if(isset($details[0]->parts)) $attach = 'yes'; else $attach = 'no'; if($status='unread') { $mail[$i] = (array( 'subject' => $subject, 'status' => $status, 'from' => $from, 'date' => $date, 'attach' => $attach ) ); } }// endforeach } // endif if(count($mail) < 0) { return 'Alert: No mail in your inbox ('.$user.')'; } else { return $mail; } } Link to comment https://forums.phpfreaks.com/topic/267378-imap-sort-function/ Share on other sites More sharing options...
darkfreaks Posted August 21, 2012 Share Posted August 21, 2012 if you have bother to read the manual it states using imap_sort by SORTDATE with an inbox of approx. 800 emails takes too long. and that SORTBYARRIVAL would be a better option. Link to comment https://forums.phpfreaks.com/topic/267378-imap-sort-function/#findComment-1371148 Share on other sites More sharing options...
trq Posted August 22, 2012 Share Posted August 22, 2012 Also, your _connection method will always return a string. You can only return a single value from a function. Link to comment https://forums.phpfreaks.com/topic/267378-imap-sort-function/#findComment-1371325 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.