php imap,只有发件人的电子邮件才能获得结果

I am wanting to return emails of a specified senders email address only using IMAP and PHP, however the only example ive found that i can get working returns all emails, due to the amount of emails stored the code below takes a long time and often times out.

i have zero experience with this, and have read the php.net manual along with other resources so come to a dead end.

$mbox = imap_open("{outlook.office365.com:993/ssl}INBOX", "email-xxx", "pass-xxx")
     or die("can't connect: " . imap_last_error());

$MC = imap_check($mbox);

// Fetch an overview for all messages in INBOX
$result = imap_fetch_overview($mbox,"1:{$MC->Nmsgs}",0);

var_dump($result);

You can use imap_search().

array imap_search ( resource $imap_stream , string $criteria [, int $options = SE_FREE [, string $charset = NIL ]] )

To get only mails from foo@bar.baz:

$result = imap_search($mbox, 'FROM foo@bar.baz');