Archive for December, 2010

PHP script to download files from GMail

Wednesday, December 15th, 2010

While my wife was getting a valuable two hours of sleep before she was woken with contractions signaling the birth of our first born child 19 hours later, I was not quite tired enough to sleep. UnknowingIy missing out on my last chance to sleep for a while, I was typing away at a PHP script to allow us to share pictures of our new baby – whenever he was going to arrive – with our friends and family privately with nothing more complex than the ability to eMail photos from my iPhone.

It was important to us to be able to share these pictures of our new child, but also to protect our child’s image from the very public exposure of the public internet and the still too public (or at least, un-trustable privacy of) Facebook.

Here’s how I was able to achieve this with a web server, some PHP, a GMail account and my iPhone:

Creating Galleries
First off I created a folder with standard Apache Basic Auth settings and let our friends and family know the simple username and password. I also turned on WebDAV access for the geekier viewers. In order to construct interesting galleries I placed a copy of Qdig, a Quick Digital Image Gallery PHP script to create galleries and thumbnails on the fly (and secured it against the WebDAV access). I had to increase the amount of RAM PHP could use, but otherwise it was very easy to implement.

Getting eMail Attachements from GMail with PHP

I created a new GMail account (specifically through my Google Apps domain) to receive all of these cute baby pictures via eMail from my iPhone. The next step was to check it automatically and store the attached pictures in a specific folder.