PHP imap_search在Sent文件夹中不起作用

I am integrating an email box feature into a PHP web application and I need to be able to search through my emails using a filter on the subject. Specifically, I need to search for the emails which contain a certain keyword in their subject.

To do that, I am using the imap_search function.

When I use imap_search in my INBOX folder, it works fine and I do get the emails I am looking for.

But if I try to use imap_search in any other folder (for example, my Sent folder), zero email get returned, even if I use a keyword that I know is featured in some of my emails' subjects

I am successfully connecting to my Sent folder using imap_open. Additionally, imap_sort manages to fetch all the emails in the folder It is only when I try imap_search that I have an issue.

My code :

//the path for the sent folder was confirmed by using imap_list()
$sent = imap_open("{imap.mydomain.com:143/novalidate-cert}Sent", $login, $pwd);

$search = "SUBJECT \"test\"";

imap_sort($sent, SORTDATE, 1);   //this works and returns an array of emails
imap_search($sent, $search);     //this returns bool(false)

Does anyone know what I'm doing wrong?