PHP imap_search UID SEARCH returns false
Asked Answered
E

1

2

I am using PHP's imap functions and want to retrieve emails with a UID > n. This works when searching dates but not UIDs.

$imap = imap_open($host, $username, $password);
$emails = imap_search($imap, 'SINCE "8 September 2016"');

var_dump($emails);

This outputs:

array(16) {
  [0]=>int(30)
  [1]=>int(31)
  [2]=>int(32)
  [3]=>int(33)
  [4]=>int(34)
  [5]=>int(35)
  [6]=>int(36)
  [7]=>int(37)
  [8]=>int(38)
  [9]=>int(39)
  [10]=>int(40)
  [11]=>int(41)
  [12]=>int(42)
  [13]=>int(43)
  [14]=>int(44)
  [15]=>int(45)
}

When I try searching by UID:

$emails = imap_search($imap, 'UID SEARCH UID 1:*');

var_dump($emails);

This outputs:

bool(false)

Any ideas would be appreciated.

Erda answered 9/9, 2016 at 1:5 Comment(3)
search is not a criteria of imap_search. php.net/manual/en/function.imap-search.php Maybe you want TEXT..Volz
You just want UID 1:*.Wiseacre
Sorry, neither of these suggestions work eitherErda
M
6

Use:

$emails = imap_fetch_overview($inbox, "1:*", FT_UID);
var_dump($emails);
Marrin answered 16/3, 2017 at 8:12 Comment(2)
This works! Any idea why imap_search($inbox, "UID 1:*", SE_UID) doesn't?Samirasamisen
According to php.net/manual/en/function.imap-search.php "imap_search($inbox, "UID 1:*", SE_UID)" is not validAbidjan

© 2022 - 2024 — McMap. All rights reserved.