首页 >函数列表 >imap_search

imap_search

imap_search

(PHP 4, PHP 5)

imap_searchThis function returns an array of messages matching the given search criteria

说明

array imap_search ( resource $imap_stream , string $criteria [, int $options = SE_FREE [, string $charset = NIL ]] )

This function performs a search on the mailbox currently opened in the given IMAP stream.

For example, to match all unanswered messages sent by Mom, you'd use: "UNANSWERED FROM mom". Searches appear to be case insensitive. This list of criteria is from a reading of the UW c-client source code and may be incomplete or inaccurate (see also » RFC2060, section 6.4.4).

参数

imap_stream

imap_open() 返回的 IMAP 流。

criteria

A string, delimited by spaces, in which the following keywords are allowed. Any multi-word arguments (e.g. FROM "joey smith") must be quoted. Results will match all criteria entries.

  • 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
options

Valid values for options are SE_UID, which causes the returned array to contain UIDs instead of messages sequence numbers.

charset

返回值

Returns an array of message numbers or UIDs.

Return FALSE if it does not understand the search criteria or no messages have been found.

更新日志

版本 说明
4.3.3 The charset parameter was added

范例

Example #1 imap_search() example

<?php
$conn   
imap_open('{imap.example.com:993/imap/ssl}INBOX''foo@example.com''pass123'OP_READONLY);

$some   imap_search($conn'SUBJECT "HOWTO be Awesome" SINCE "8 August 2008"'SE_UID);
$msgnos imap_search($conn'ALL');
$uids   imap_search($conn'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() - Returns the list of mailboxes that matches the given text

  • imap_8bit
  • imap_alerts
  • imap_append
  • imap_base64
  • imap_binary
  • imap_body
  • imap_bodystruct
  • imap_check
  • imap_clearflag_full
  • imap_close
  • imap_create
  • imap_createmailbox
  • imap_delete
  • imap_deletemailbox
  • imap_errors
  • imap_expunge
  • imap_fetchbody
  • imap_fetchheader
  • imap_fetchmime
  • imap_fetchstructure
  • imap_fetchtext
  • imap_fetch_overview
  • imap_gc
  • imap_getacl
  • imap_getmailboxes
  • imap_getsubscribed
  • imap_get_quota
  • imap_get_quotaroot
  • imap_header
  • imap_headerinfo
  • imap_headers
  • imap_last_error
  • imap_list
  • imap_listmailbox
  • imap_listscan
  • imap_listsubscribed
  • imap_lsub
  • imap_mail
  • imap_mailboxmsginfo
  • imap_mail_compose
  • imap_mail_copy
  • imap_mail_move
  • imap_mime_header_decode
  • imap_msgno
  • imap_num_msg
  • imap_num_recent
  • imap_open
  • imap_ping
  • imap_qprint
  • imap_rename
  • imap_renamemailbox
  • imap_reopen
  • imap_rfc822_parse_adrlist
  • imap_rfc822_parse_headers
  • imap_rfc822_write_address
  • imap_savebody
  • imap_scan
  • imap_scanmailbox
  • imap_search
  • imap_setacl
  • imap_setflag_full
  • imap_set_quota
  • imap_sort
  • imap_status
  • imap_subscribe
  • imap_thread
  • imap_timeout
  • imap_uid
  • imap_undelete
  • imap_unsubscribe
  • imap_utf7_decode
  • imap_utf7_encode
  • imap_utf8
  • PHP MySQL HTML CSS JavaScript MSSQL AJAX .NET JSP Linux Mac ASP 服务器 SQL jQuery C# C++ java Android IOS oracle MongoDB SQLite wamp 交通频道