Reply to Help: questions about query structure in imap_search

Your name:

Reply:


Posted by chris_fieldhouse@hotmail.com on 01/20/06 21:55

Hi,

I'm maintaing a website for a group and we have several email addresses
feeding into one inbox, so I want to find a way of finding all the
emails that were sent to a particular address either via "TO" or "CC"
(not interested in "BCC")

imap_search seems to be the solution, but there are several issues.
1. I can get imap_search($conn, "TO test_address"); to work, and
imap_search($conn, "CC test_address");, but not a combined 'OR' search
to grab the "TO" and "CC" together.
2. so using 2 searches and trying to merger the results, the issue is
that while the search returns false if no messages are found, the
returned arrays are not empty, and doing an "array_merge" results in an
array of size 2, even when no results found.


I've ended up with this rather unsatisfying piece of code, it works,
but it looks like a cludge.

<code snippet>
# now lets try searching for TO and CC emails! merge arrays,
$emailSearch1= imap_search($conn, "TO test_address");
$emailSearch2= imap_search($conn, "CC test_address");

# attempt to merge arrays
$emailSearch= array_merge ($emailSearch1, $emailSearch2);

# if one array is 'empty', just assign the other array to be the search
result
if($emailSearch1 == false) $emailSearch=$emailSearch2;
if($emailSearch2 == false) $emailSearch=$emailSearch1;

$numEmails = sizeof($emailSearch);
if($emailSearch == false) $numEmails=0;


Can any of you experts recommend a better way of performing the
imap_search and merging the results?

Thanks in advance.

Chris

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация