0

How can I perform a imap_search an then sort the result by date ?

I've tried

$imap_ressource = imap_open($server, $user, $password)
$search = imap_search($imap_ressource, 'Subject blablabla'); // to search email with same subject
$sorted = imap_sort($search , SORTARRIVAL , 1); // ERROR : imap_sort wants $imap_ressource

So who can I search stuff and sort ONLY the result, not all emails ...

Thanks

Jintor
  • 607
  • 8
  • 32
  • Does [this answer](https://stackoverflow.com/a/57689998/4205384) help? – El_Vanja Apr 03 '20 at 00:54
  • @El_Vanja I try `imap_sort($imap_ressource, SORTDATE, 1, SE_UID, 'Subject blablabla');` but when I want to go trough the given array with imap_fetchbody I get "bad message number" :( – Jintor Apr 03 '20 at 01:40
  • 2
    The `imap_sort` [documentation](https://www.php.net/manual/en/function.imap-sort) says "*SE_UID - Return UIDs instead of sequence numbers*". Replace that flag with `0` if you want the numbers. – El_Vanja Apr 03 '20 at 06:41
  • @El_Vanja Thanks ;) it worked :) can you post your comment as an answer – Jintor Apr 03 '20 at 14:00

0 Answers0