Guest User

Untitled

a guest
Nov 25th, 2017
430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. <?
  2.  
  3. /* connect to gmail */
  4. set_time_limit(0);
  5. $hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
  6. $username = 'want.unban@gmail.com';
  7. $password = 'fencer123';
  8.  
  9. /* try to connect */
  10. $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: '.imap_last_error());
  11.  
  12. /* grab emails */
  13. $emails = imap_search($inbox,'ALL');
  14.  
  15. /* if emails are returned, cycle through each... */
  16. if ($emails) {
  17.  
  18. /* begin output var */
  19. $output = '';
  20.  
  21. /* put the newest emails on top */
  22. rsort($emails);
  23. $i = 0;
  24. /* for every email... */
  25. foreach ($emails as $email_number) {
  26.  
  27. /* get information specific to this email */
  28. $overview = imap_fetch_overview($inbox,$email_number,0);
  29. $message = imap_fetchbody($inbox,$email_number,2);
  30. if (strpos(strtolower($message),'//z') === false AND strpos(strtolower($message),'///') === false AND strpos(strtolower($message),'aaa') === false AND strpos(strtolower($message),'/w') === false) {
  31. $ar[strtotime($overview[0]->date)]['subject'] = $overview[0]->subject;
  32. $ar[strtotime($overview[0]->date)]['from'] = $overview[0]->from;
  33. $ar[strtotime($overview[0]->date)]['message'] = str_replace(array('=20','= ='),'',preg_replace('/\s+/',' ',trim(strip_tags($message))));
  34. }
  35.  
  36. $i++;
  37. }
  38.  
  39. file_put_contents('emails.txt',serialize($ar));
  40. echo 'hotovo';
  41.  
  42. }
  43.  
  44. /* close the connection */
  45. imap_close($inbox);
Add Comment
Please, Sign In to add comment