IMAP, POP3 및 NNTP imap_search
(PHP 4, PHP 5, PHP 7, PHP 8)
imap_search — 이 함수는 주어진 검색 기준과 일치하는 메시지 배열을 반환합니다.
설명
imap_search( IMAP\Connection $imap, string $criteria, int $flags = SE_FREE, string $charset = "" ): array|false
이 함수는 주어진 IMAP 스트림에서 현재 열려 있는 편지함에서 검색을 수행합니다.
예를 들어 Mom이 보낸 응답하지 않은 모든 메시지를 일치시키려면 "UNANSWERED FROM mom"을 사용합니다. 검색은 대소문자를 구분하지 않는 것 같습니다. 이 기준 목록은 UW c-client 소스 코드를 읽고 불완전하거나 정확하지 않을 수 있습니다(» RFC1176, '태그 SEARCH search_criteria' 섹션 참조).
매개변수
imap
- IMAP\Connection 인스턴스입니다.
criteria
공백으로 구분된 문자열로 다음 키워드가 허용됩니다. 여러 단어로 된 인수(예: FROM "joey smith")는 따옴표로 묶어야 합니다. 결과는 모든
criteria
항목과 일치합니다.- ALL - return all messages matching the rest of the criteria
- ANSWERED - match messages with the \\ANSWERED flag set
- BCC "string" - match messages with "string" in the Bcc: field
- BEFORE "date" - match messages with Date: before "date"
- BODY "string" - match messages with "string" in the body of the message
- CC "string" - match messages with "string" in the Cc: field
- DELETED - match deleted messages
- FLAGGED - match messages with the \\FLAGGED (sometimes referred to as Important or Urgent) flag set
- FROM "string" - match messages with "string" in the From: field
- KEYWORD "string" - match messages with "string" as a keyword
- NEW - match new messages
- OLD - match old messages
- ON "date" - match messages with Date: matching "date"
- RECENT - match messages with the \\RECENT flag set
- SEEN - match messages that have been read (the \\SEEN flag is set)
- SINCE "date" - match messages with Date: after "date"
- SUBJECT "string" - match messages with "string" in the Subject:
- TEXT "string" - match messages with text "string"
- TO "string" - match messages with "string" in the To:
- UNANSWERED - match messages that have not been answered
- UNDELETED - match messages that are not deleted
- UNFLAGGED - match messages that are not flagged
- UNKEYWORD "string" - match messages that do not have the keyword "string"
- UNSEEN - match messages which have not been read yet
flags
flags
에 유효한 값은SE_UID
이며, 이로 인해 반환된 배열에 메시지 시퀀스 번호 대신 UID가 포함됩니다.charset
- 문자열을 검색할 때 사용할 MIME 문자 집합입니다.
반환 값
메시지 번호 또는 UID의 배열을 반환합니다.
검색 criteria
을 이해하지 못하거나 메시지가 발견되지 않으면 false
를 반환합니다.
변경 로그
버전 | 설명 |
---|---|
8.1.0 | imap 매개변수는 이제 IMAP\Connection 인스턴스를 필요로 합니다. 이전에는 리소스가 필요했습니다. |
Examples
예제 #1 imap_search() 예제
<?php
$imap = imap_open('{imap.example.com:993/imap/ssl}INBOX', 'foo@example.com', 'pass123', OP_READONLY);
$some = imap_search($imap, 'SUBJECT "HOWTO be Awesome" SINCE "8 August 2008"', SE_UID);
$msgnos = imap_search($imap, 'ALL');
$uids = imap_search($imap, 'ALL', SE_UID);
print_r($some);
print_r($msgnos);
print_r($uids);
?>
위의 예는 다음과 유사한 결과를 출력합니다.
Array ( [0] => 4 [1] => 6 [2] => 11 ) Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 ) Array ( [0] => 1 [1] => 4 [2] => 6 [3] => 8 [4] => 11 [5] => 12 )
기타
- imap_listscan() - 주어진 텍스트와 일치하는 사서함 목록을 반환합니다.