0

In Gmail, new emails are displayed instantaneously without page refresh. I can retrieve my gmail emails using PHP and IMAP. How could I implement or add this instantaneous/constant sync without page refresh? Here is the basic code:

http://pastebin.com/ivfbMSZk

$inbox = imap_open($hostname,$username,$password,NULL,1) or die('Cannot connect to Gmail: ' . print_r(imap_errors()));
$emails = imap_search($inbox,'ALL');
if($emails) {
     $output = '';
     rsort($emails);
     foreach($emails as $email_number) {
          $message = imap_fetchbody($inbox,$email_number,1);
          $output.= $message;
     }
     echo $output . "\n";       
}
todor
  • 3
  • 3

1 Answers1

0

You would need something like the comet model, there are questions like this one rewarding this subject, on this, php works for light traffic only.

Community
  • 1
  • 1
Jaibuu
  • 560
  • 3
  • 9