|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-11-19 19:30 UTC] hm2k@php.net
Description: ------------ --- From manual page: http://www.php.net/function.imap-search --- The imap_search() function almost always returns false with no hint or indication as to why. Test script: --------------- <pre> <?php ini_set('display_errors','On'); error_reporting(E_ALL); include 'settings.php'; //connect to mailbox $stream=imap_open('{'.$host.'/imap/notls/norsh/novalidate-cert/readonly}INBOX',$user,$pass,OP_SILENT); echo "imap_mailboxmsginfo\n"; var_dump(imap_mailboxmsginfo($stream)); echo "\n"; //searches $searches=array(); $searches[]='ALL'; $searches[]='ANSWERED'; $searches[]='BCC "@"'; $searches[]='BEFORE 19-11-2010'; $searches[]='SINCE 1-1-1970'; $searches[]='SINCE 01-01-1970'; $searches[]='SINCE 01-Jan-1970'; $searches[]='SINCE "1-1-1970"'; $searches[]='SINCE "1-Jan-1970"'; $searches[]='SINCE "17-Jul-1996 02:44:25 -0700"'; $searches[]='SINCE "17 Nov 2008"'; foreach ($searches as $search) { echo "imap_search $search\n"; var_dump(imap_search($stream,$search)); //bool(false) if (imap_last_error()) { echo 'Error: '.imap_last_error()."\n"; } echo "\n"; } Expected result: ---------------- Returns an array of message numbers or UIDs. Actual result: -------------- imap_mailboxmsginfo object(stdClass)#1 (8) { ["Unread"]=> int(70) ["Deleted"]=> int(0) ["Nmsgs"]=> int(974) ["Size"]=> int(19740065) ["Date"]=> string(37) "Sat, 20 Nov 2010 02:50:34 +0000 (GMT)" ["Driver"]=> string(4) "imap" ["Mailbox"]=> string(96) "{mail.example.com:143/imap/notls/novalidate-cert/readonly/user="email@example.com"}INBOX" ["Recent"]=> int(0) } imap_search ALL bool(false) imap_search ANSWERED bool(false) imap_search BCC "@" bool(false) imap_search BEFORE 19-11-2010 bool(false) Error: Unknown search criterion: BEFORE imap_search SINCE 1-1-1970 bool(false) Error: Unknown search criterion: SINCE imap_search SINCE 01-01-1970 bool(false) Error: Unknown search criterion: SINCE imap_search SINCE 01-Jan-1970 bool(false) Error: Unknown search criterion: SINCE imap_search SINCE "1-1-1970" bool(false) Error: Unknown search criterion: SINCE imap_search SINCE "1-Jan-1970" bool(false) Error: Unknown search criterion: SINCE imap_search SINCE "17-Jul-1996 02:44:25 -0700" bool(false) Error: Unknown search criterion: SINCE imap_search SINCE "17 Nov 2008" bool(false) Error: Unknown search criterion: SINCE Notice: Unknown: Unknown search criterion: BEFORE (errflg=2) in Unknown on line 0 Notice: Unknown: Unknown search criterion: SINCE (errflg=2) in Unknown on line 0 Notice: Unknown: Unknown search criterion: SINCE (errflg=2) in Unknown on line 0 Notice: Unknown: Unknown search criterion: SINCE (errflg=2) in Unknown on line 0 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 15 12:00:01 2025 UTC |
Looking at your test script, it appears that you are sending each segment of the imap_search command as a separate call. The documentation clearly states that the "criteria" parameter is a space-delimited set of filtering commands which are sent as a single call. I'm setting this bug to Feedback while you try modifying your script to, instead of looping through $searches, implode it with space "glue". An example would be: var_dump(imap_search($stream,implode(' ', $searches))); If you continue to have issues with it, respond with the result. I'd rather not have to set up the extension on my system to test what seems like a simple EBCAK ;).