PHP imap_search UID SEARCH returns false

2019-06-06 09:58发布

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.

标签: php imap
1条回答
forever°为你锁心
2楼-- · 2019-06-06 10:32

Use:

$emails = imap_fetch_overview($inbox, "1:*", FT_UID);
var_dump($emails);
查看更多
登录 后发表回答