Guest User

Untitled

a guest
Mar 16th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. <?php
  2. // Report simple running errors
  3. error_reporting(E_ERROR | E_WARNING | E_PARSE);
  4.  
  5. // Reporting E_NOTICE can be good too (to report uninitialized
  6. // variables or catch variable name misspellings ...)
  7. error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
  8.  
  9. // Report all errors except E_NOTICE
  10. // This is the default value set in php.ini
  11. error_reporting(E_ALL ^ E_NOTICE);
  12.  
  13. // Report all PHP errors (see changelog)
  14. error_reporting(E_ALL);
  15.  
  16. // Report all PHP errors
  17. error_reporting(-1);
  18.  
  19. // Same as error_reporting(E_ALL);
  20. ini_set('error_reporting', E_ALL);
  21.  
  22.  
  23. /* connect to gmail */
  24. $hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
  25. $username = 'username';
  26. $password = 'password';
  27.  
  28. /* try to connect */
  29. $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
  30.  
  31. /* grab emails */
  32. $emails = imap_search($inbox,'ALL');
  33.  
  34. /* if emails are returned, cycle through each... */
  35. if($emails) {
  36.  
  37. /* begin output var */
  38. $output = '';
  39.  
  40. /* put the newest emails on top */
  41. rsort($emails);
  42.  
  43. /* for every email... */
  44. foreach($emails as $email_number) {
  45.  
  46. /* get information specific to this email */
  47. $overview = imap_fetch_overview($inbox,$email_number,0);
  48. $message = imap_fetchbody($inbox,$email_number,2);
  49.  
  50. /* output the email header information */
  51. $output.= '<div class="toggler '.($overview[0]->seen ? 'read' : 'unread').'">';
  52. $output.= '<span class="subject">'.$overview[0]->subject.'</span> ';
  53. $output.= '<span class="from">'.$overview[0]->from.'</span>';
  54. $output.= '<span class="date">on '.$overview[0]->date.'</span>';
  55. $output.= '</div>';
  56.  
  57. /* output the email body */
  58. $output.= '<div class="body">'.$message.'</div>';
  59. }
  60.  
  61. echo $output;
  62. }
  63.  
  64. /* close the connection */
  65. imap_close($inbox);
  66.  
  67. ?>
Add Comment
Please, Sign In to add comment