Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2017
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. /* connect to gmail */
  2. $hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
  3. $username = 'X';
  4. $password = 'X';
  5. /* try to connect */
  6. $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
  7. /* grab emails */
  8. $emails = imap_search($inbox,'ALL');
  9. /* if emails are returned, cycle through each... */
  10. if($emails) {
  11. /* begin output var */
  12. $output = '';
  13. /* put the newest emails on top */
  14. rsort($emails);
  15. /* for every email... */
  16. foreach($emails as $email_number) {
  17. /* get information specific to this email */
  18. $overview = imap_fetch_overview($inbox,$email_number,0);
  19. $message = imap_fetchbody($inbox,$email_number,2);
  20. /* output the email header information */
  21. $output.= '<div class="toggler '.($overview[0]->seen ? 'read' : 'unread').'">';
  22. $output.= '<span class="subject">'.$overview[0]->subject.'</span> ';
  23. $output.= '<span class="from">'.$overview[0]->from.'</span>';
  24. $output.= '</div>';
  25.  
  26. }
  27. echo $test , $test , $output;
  28. }
  29. imap_close($inbox);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement