Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2017
549
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. <?
  2. /* connect to gmail */
  3. $hostname = '{imap.gmail.com:993/imap/ssl/novalidate-cert}fax';
  4. $username = 'webfax@nmsell.com';
  5. $password = 'xxxxxx';
  6.  
  7. /* try to connect */
  8. $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
  9.  
  10. /* grab emails */
  11. $emails = imap_search($inbox,'ALL');
  12.  
  13. /* if emails are returned, cycle through each... */
  14. if($emails) {
  15.  
  16. /* begin output var */
  17. $output = '';
  18.  
  19. /* put the newest emails on top */
  20. rsort($emails);
  21.  
  22. /* for every email... */
  23. foreach($emails as $email_number) {
  24.  
  25. /* get information specific to this email */
  26. $overview = imap_fetch_overview($inbox,$email_number,0);
  27. $message = imap_fetchbody($inbox,$email_number,1);
  28.  
  29. /* output the email header information */
  30. $output.= '<b>subject</b>'.$overview[0]->subject.'<br> ';
  31. $output.= '<b>from</b>'.$overview[0]->from.'<br>';
  32. $output.= '><b>date</b>on '.$overview[0]->date.'<br>';
  33.  
  34. /* output the email body */
  35. $output.= '<b>body</b>'.$message.'<br><br>';
  36. }
  37.  
  38. echo $output;
  39. }
  40.  
  41. /* close the connection */
  42. imap_close($inbox);
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement