PHP imap loop help please?

Phil

New member
hi guys,

i'm trying to make a bot that reads emails from an imap inbox and when it gets a message with a certain cmd inside the body it does something.

I know how to do the cmd bit, its the loop i cant get to work.

I have:

<?php

while(1) {
$headers = imap_header($mbox);
$mail_count = imap_num_msg($mbox);
echo "YOU HAVE { $mail_count } MESSAGE(S) AS OF { ".date("h:i:s")." }<br><br>";
}

this works as far as it gets the number of emails in the box (woo) and prints out the echo line properly (double woo).

What its not doing is updating the number of emails in the inbox each time the loop refreshes its self - say our first run says i have 3 emails, it will say 3 emails for every check even if i send another 5 emails and check my webmail and it updates on there with the proper number.

Any ideas why it isnt updating and how i can fix?

thanks!
EDIT: To clarify YES while(1) causes an infinate loop...i'm using it now...

Yes there is a reason i have no breaks thats just for testing. To stop the script i just have to direct to another page.
EDIT 2: I am not lookin fr help on the loop, its the "why isn't the mail count updating" bit.
 
Back
Top