Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
- $username = 'someemail@somedomain.com';
- $password = 'somepassword';
- /* try to connect */
- $imap_connection = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
- /* grab emails */
- $emails = imap_search($imap_connection,'ALL');
- /* if emails are returned, cycle through each... */
- if($emails) {
- /* begin output var */
- $output = '';
- /* put the newest emails on top */
- rsort($emails);
- /* for every email... */
- foreach($emails as $email_number) {
- $structure = imap_fetchstructure($imap_connection,$email_number);
- if(isset($structure->parts) && count($structure->parts)){
- for($i = 0; $i < count($structure->parts); $i++){
- if(!empty($structure->parts[$i]->bytes)){
- if(!empty($ifdparameters)){
- echo "File: ----".$structure->parts[$i]->dparameters[0]->value;
- // returns: testMeOut.jpg
- }
- }
- } //eof $i loop
- } //eof $structure->parts
- } // eof foreach $emails
- } // eof if($emails)
- ?>
Add Comment
Please, Sign In to add comment