Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 964453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:49:46+00:00 2026-05-16T01:49:46+00:00

can you please tell , how to download attachments from gmail account using php

  • 0

can you please tell , how to download attachments from gmail account using php ?
thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T01:49:47+00:00Added an answer on May 16, 2026 at 1:49 am

    IMAP Solution

    /* connect to gmail */
    $hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
    $username = 'davidwalshblog@gmail.com';
    $password = 'davidwalsh';
    
    /* try to connect */
    $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
    
    /* grab emails */
    $emails = imap_search($inbox,'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) {
    
            /* get information specific to this email */
            $overview = imap_fetch_overview($inbox,$email_number,0);
            $message = imap_fetchbody($inbox,$email_number,2);
    
            /* output the email header information */
            $output.= '<div class="toggler '.($overview[0]->seen ? 'read' : 'unread').'">';
            $output.= '<span class="subject">'.$overview[0]->subject.'</span> ';
            $output.= '<span class="from">'.$overview[0]->from.'</span>';
            $output.= '<span class="date">on '.$overview[0]->date.'</span>';
            $output.= '</div>';
    
            /* output the email body */
            $output.= '<div class="body">'.$message.'</div>';
        }
    
        echo $output;
    } 
    
    /* close the connection */
    imap_close($inbox);
    

    You must add to it attachment control and you can read this because from it is this source code http://davidwalsh.name/gmail-php-imap

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could someone please tell me which objects types can be tested using Regular Expressions
Can someone please tell me where these extra characters are coming from? This is
Can you please tell me how much is (-2) % 5 ? According to
Can anyone please tell me if Certifying Authorities (CAs) are allowed to make modifications
Can someone please derive a concrete example from the following: http://www.urdalen.com/blog/?p=210 ..that shows how
Can you please tell me how can I install scons on MacOSX? I don't
Can anyone please tell me the disadvantages of storing images in a MySQL database?
Can someone please tell me where I'm going wrong with this piece of code?
Can someone please tell me how I can get the changeset number, the current
Can someone please tell what this strange error is Mod_python error: PythonHandler django.core.handlers.modpython Traceback

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.