Guest User

Untitled

a guest
Jan 18th, 2019
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. <?php
  2.  
  3. $hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
  4. $username = 'someemail@somedomain.com';
  5. $password = 'somepassword';
  6.  
  7. /* try to connect */
  8. $imap_connection = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
  9.  
  10. /* grab emails */
  11. $emails = imap_search($imap_connection,'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. $structure = imap_fetchstructure($imap_connection,$email_number);
  26. if(isset($structure->parts) && count($structure->parts)){
  27.  
  28. for($i = 0; $i < count($structure->parts); $i++){
  29.  
  30.  
  31. if(!empty($structure->parts[$i]->bytes)){
  32.  
  33. if(!empty($ifdparameters)){
  34. echo "File: ----".$structure->parts[$i]->dparameters[0]->value;
  35. // returns: testMeOut.jpg
  36.  
  37. }
  38. }
  39.  
  40.  
  41. } //eof $i loop
  42.  
  43.  
  44. } //eof $structure->parts
  45.  
  46.  
  47. } // eof foreach $emails
  48.  
  49. } // eof if($emails)
  50.  
  51. ?>
Add Comment
Please, Sign In to add comment