Code Tidy - Pastebin

New     Fork     Embed     View raw     Report

Check Gmail and Display Unread Messages - php

Embed

You can embed this paste into a blog or website with this code:

<iframe class="codetidy" type="text/html" width="100%" src="http://codetidy.com/paste/embed/306" frameborder="0"></iframe>

Add comment

Captcha
  1. <?php?
  2.  ?
  3. $mailbox = '{imap.gmail.com:993/ssl/novalidate-cert}INBOX';?
  4. $username = $_GET['username'];?
  5. $password = $_GET['password'];?
  6. $msg = $_GET['msg'];?
  7.  ?
  8.  ?
  9. $mbox = imap_open($mailbox, $username, $password);?
  10. $n = imap_num_msg($mbox);?
  11.  ?
  12. //$imap_obj = imap_check($mbox);?
  13. //var_dump($imap_obj);?
  14.  ?
  15. //echo "<br><hr>";?
  16. //echo $n;?
  17. //echo " total messages.";?
  18. //echo "<br><hr>";?
  19. //$body = imap_body($mbox, $msg);?
  20.  ?
  21. $unread = 0;?
  22. for ($i = $n; $i >= $n-70; $i--) {      ?
  23.       $header = imap_headerinfo($mbox, $i);?
  24.       if ($header->Unseen == "U"){?
  25.         $unread ++;?
  26.       }?
  27. }?
  28. echo "#".$unread; ?
  29.  ?
  30. ?>?
© 2011 Code Tidy