News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Sameer Borate's Blog:
Downloading Gmail attachments using PHP
May 08, 2012 @ 09:08:40

Sameer Borate has a quick tutorial posted to his site today about using PHP, specifically the IMAP functionality, to grab attachments off of emails from Gmail.

Automatically extracting attachments from Gmail can be important for reasons where you need to process the attached files periodically with a CRON job. Also it can be useful for automatically archiving important attachments. Below is a simple proof-of-concept plain PHP code, devoid of any object-oriented features that extracts attachments from your Gmail account. It uses PHPs imap extension to access the inbox.

His simple script opens an IMAP connection to the Gmail server and loops through your current emails (max of 16) and tries to find any that have attachments. It then extracts this part of the message, base64_decodes it, and saves the set of them to the local file system. You can download the source here.

0 comments voice your opinion now!
gmail attachment tutorial download imap


blog comments powered by Disqus

Similar Posts

Ilia Alshanetsky's Blog: 5.2.4 RC1 Released

Semaphoreapp.com: Continuous Integration & Deployment of PHP applications from GitHub to Heroku

Ilia Alshanetsky's Blog: FUDforum 2.7.7RC1 is out!

WebReference.com: User Personalization with PHP: The Home Page

Ryan Mauger's Blog: Using Twig with Zend Framework


Community Events

Don't see your event here?
Let us know!


series example api performance opinion application community configure voicesoftheelephpant library podcast laravel framework introduction php7 release symfony2 interview conference part2

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework