troubleshooting Question

IMAP multiple searches - array_intersect and PHP 7.4 Problem

Avatar of dogsareit
dogsareitFlag for United States of America asked on
PHP
7 Comments1 Solution12 ViewsLast Modified:
I need to do a multiple search on an email box. I am using PHP 7.4.
I know imap has  a problem with multiple search criteria from everything I have read.
So I thought I would issue a search for each criteria and then use array_intersect  with the results of each  search giving me exactly what I want.
I want to select only emails that match a 'from' email address and the subject line is 'INVOICE'
The 'from' address will vary - it's read from a table.
But I can not seem to get the syntax correct.  I keep receiving: Notice: Undefined variable: emails.
And it should contain two valid email that match the search criteria of the 'from' address and the subject line  'INVOICE'. But it does not work.
Any help appreciated. And thank you in advance.
 $strFromEmail  = 'testir@gmail.com';

 $arrayFrom = imap_search($inbox, 'FROM "' .  $strFromEmail . '"'', SE_UID);
 
 $arrayInvoice = imap_search($inbox, 'SUBJECT "INVOICE"', SE_UID);
 
 if((!empty($arrayFrom)) && (!empty($arrayInvoice)))
 {
   $emails = array_intersect($arrayFrom, $arrayInvoice);
 }


Open in new window




ASKER CERTIFIED SOLUTION
dogsareit
Owner

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros