tags:

views:

45

answers:

4

Hi, I'm trying to figure out a way to do the following with php:

Have a website (index.php) check an e-mail inbox every 15 seconds or so, read the subject line, and the contents of the message, and then display that message on the screen. The idea being it will display all the messages in the inbox on the index.php page as they get sent in. And I guess the index.php page will also have to refresh whenever there is a new message to display the content.

Thanks!

A: 

Bad idea. If your page refreshes every 15 seconds, nobody will ever be able to click on anything because as soon as the page refreshes, it will start refreshing again.

What you probably want is something more ajaxy, like gmail uses. This does the refresh in the background so the page itself doesn't refresh. There are lots of tutorials on how to do this. For example This, which you can extrapolate out to what you want.

Mystere Man
A: 

Dump the email contents into a database or some kind of flat file and use its contents to display.

If your using gmail: http://framework.zend.com/download/gdata

B00MER
+1  A: 

I think an interval of less than a minute is rather difficult to realize and/or rather expensive to run. If you need that high a frequency, you should be better off by writing a hook for your mail handler that gets triggered whenever new mail arrives. How to do that depends on your mail handler.

deceze
A: 
  1. Create a script that hooks or polls the mail server inbox for changes.
  2. Store new emails using memcached
  3. Create a RESTful web service that simply checks the memcached for new emails, returning as JSON
  4. Use jQuery or another javascript framework's AJAX functionality to retrieve new emails in JSON format from the RESTful web service and bind the results to the DOM of the current page. Use javascript fade-in animation for better usability.
burkestar