Advertisement
Guest User

Untitled

a guest
Dec 26th, 2016
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. <?php
  2.  
  3. $imapPath = '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX';
  4. $username = 'example@gmail.com';
  5. $password = 'password.';
  6.  
  7. $inbox = imap_open($imapPath, $username, $password) or die('Cannot connect to Gmail: ' . imap_last_error());
  8.  
  9. $emails = imap_search($inbox, 'ALL');
  10.  
  11. //$count=0;
  12. foreach ($emails as $mail) {
  13. $overview = imap_fetch_overview($inbox, $mail);
  14. $u_id = $overview[0]->uid;
  15. if ($u_id == 343) { //12 is message unigue id
  16. $headerInfo = imap_headerinfo($inbox, $mail);
  17.  
  18. $structure = imap_fetchstructure($inbox, $mail);
  19. if (isset($structure->parts) && is_array($structure->parts) && isset($structure->parts[1])) {
  20.  
  21. $part = $structure->parts[1];
  22. $message = imap_fetchbody($inbox, $mail, '2');
  23.  
  24. if ($part->encoding == 3) {
  25. $message = imap_base64($message);
  26. echo $message;
  27. echo "<br><b>base64</b><br>";
  28. } else if ($part->encoding == 1) {
  29. $message = imap_8bit($message);
  30. echo $message;
  31. echo "<br><b>imap_8bit</b><br>";
  32. } else {
  33. $message = imap_qprint($message);
  34. echo $message;
  35. echo "<br><b>imap_qprint</b><br>";
  36. }
  37.  
  38. }
  39.  
  40. }
  41. }
  42. imap_expunge($inbox);
  43. imap_close($inbox);
  44.  
  45.  
  46. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement