2014-03-19 5 views
0

전자 메일을 받으면 전자 메일을 생성하는 고객 지원 시스템이 있습니다. 필자는 postfix와 특수 구성을 사용하여 추가 기능을 추가하기 위해 전자 메일을 보류했습니다.ImapMailbox.php를 사용하여 Imap 사서함을 날짜순으로 정렬

예를 들어 전자 메일에서 보낸 첨부 파일을 포함하고 싶습니다. 시스템은이 작업을 수행하지 않지만 제목이 포함 된 전자 메일을 생성하므로 첨부 파일을 제목과 일치시켜 포함시킬 수 있습니다.

나는 ImapMailBox.php를 사용하여 이메일 내용을 읽었습니다. 모두 정상적으로 작동하지만 마지막 이메일을 가져 오는 중에 문제가 발생하므로 동일한 제목의 다른 이메일에서 gettign 내용을 가져와 최신 이메일을 가져와야합니다.

$mailboxP = new ImapMailbox('{127.0.0.1:143/novalidate-cert}',POSTFIX_EMAIL,POSTFIX_PASSWORD,ATTACHMENT_DIR, 'utf-8'); 
foreach($mailbox->searchMails('ALL') as $mailId) 
$mail = $mailbox->getMail($mailId); 
$mailx=(array)$mail; 
$att=$mailx['attachments']; 

제가 또한 시도이

 function mysort($a,$b) { 
     return strtotime($a['date'])-strtotime($b['date']); 

     } 

같은 기능이

 function 
    mysort($a,$b) { 
    return strtotime($a->date)-strtotime($b->date); 

    } 

같은 기능 및 배열에 대물 $의 메일에 usort 사용 시도 $ mail과 $ mailx에 imap_sort를 사용하고 있지만 이것의 아무 것도 작동하지 않는다. 내가

imap_sort() expects parameter 1 to be resource, array given 
imap_sort() expects parameter 1 to be resource, object given 
usort() expects parameter 1 to be array, object given 
when passing an array I get undefined index date but it defined .. 

얻고있다 오류는 사람이 올바른 방향으로 날 가리 키도록 친절하게도 주시기 바랍니다 수 있습니다.

답변

2

당신은 ImapMailbox.php에 다음과 같은 기능을 추가 할 수 있습니다

public function searchMailsSorted($imapCriteria = 'ALL') { 
      $this->checkConnection(); 
      $mailsIds =imap_sort($this->mbox,SORTDATE,1,SE_UID,$imapCriteria,$this->serverEncoding); 


      return $mailsIds ? $mailsIds : array(); 
    }  

을 그리고 다음과 같이 코드에서 사용 :

foreach($mailbox->searchMailsSorted('ALL') as $mailId) 
{ 
///insert code here 
}