Simple IMAP Help
Posted: Thu Mar 01, 2007 8:37 pm
hawleyjr | Please use
hawleyjr | Please use[/syntax]
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Beginner problem.
I have a little piece of code that will search a mailbox for the string "hello" within the subject of unread messages. It will display which message number the string lies in, if any. My problem lies in the "number of messages found" and the "match found in."
If 14 messages are found with the string it will display each message # that it is found in as well as a total of 14.
If 0 messages are found with the string it will display "0 Match found in number:" This is fine because I will not need this line, it's just for debugging purposes.
The problem is that the "Number of Messages Found:" will display 1, which would be incorrect.
Any suggestions? I've looked around quite a bit and can't find the answer. Everything I seem to do that corrects the incorrect count of 1 will subtract 1 from any answer that is correct. Thanks for your time.
[syntax="php"]
//open imap stream
$mail = imap_open("{pop.server.com}INBOX","user","password");
// search only in the subject of unread messages for the string 'hello'
$search_mail = imap_search($mail, "UNSEEN SUBJECT hello");
for ($i=0; $i<count($search_mail); $i++) {
echo "$i Match found in number: $search_mail[$i]<BR>\n";
}
echo "<br /><b>Number of Messages Found: $i</b><br /><br />";
imap_close($mail);hawleyjr | Please use[/syntax]
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]