Monday, May 17. 2004

Recently I had opportunity to obtain a Gmail account (thanks James). For those you living under a rock it's the latest fad as far as free e-mail is concerned from the same people who brought us Google. The biggest attraction of Gmail is the 1,000 megabyte storage box and saner(?) monetization model that will rely upon the same text ads you may have seen near Google's search results, rather then big bulky banners and/or popup variations. At this time the system is in beta stage, so to get an account you first must be invited by an existing member, but only some members can invite (I am not one of them, so don't bother asking). While my initial plan for this account was to use it as the handler for mail comming to my @php.net account, which now a days comprises mostly of spam and windows viruses. Rather then have my server perform slow analysis on some 2-3 thousand messages, I'd let Google's Gmail do it for me.

Since most of the e-mail going to that account ended up being removed by spam filters, which seem to be quite good the account ended being rather empty, which seems rather wasteful.

So, I've come up with a quick utility to make use of at least a small portion of the available space for backup purposes. To accomplish this task I wrote a small PHP script that can be used to backup files to Gmail and then quickly retrieve them back if and when you need them. I trust that Gmail servers are fairly reliable, and this offers an excellent offsite backup that is extremely fast (I can max out my connection on download 300k/sec) and accessible from anywhere internet is available. Given that you do have 1gig of space quite a few things can be backed up .

P.S. The script can probably be optimized to run a little faster by removing regex and making cURL use Keep-Alive, but given that most of the time is spent retrieving the file that is not a big concern at the moment.

I thought of this too
But fortunately there is someone who actually took the initiative to do something with this: Gmail as an online backup system. [via Inquirer via MSFN via LHW comments]

Weblog: BillSaysThisTracked: Jun 20, 12:08

Gmail as an online backup system.
"I've come up with a quick utility to make use of at least a small portion of the available space for backup purposes. To accomplish this task I wrote a small PHP script that can be used to backup files...

Weblog: ritilan.comTracked: Jun 28, 10:29

Gmail for an online backup system of sorts
I've recently had the opportunity to obtain a Gmail account (thank you Walters). I'm going to start using some code (text version) of Ilia's to store stuff on gmail as a backup mechanisim. I'm thinking of PGP encrypting the files...

Weblog: Jacques Marneweck's BlogTracked: Jul 15, 03:41

File Archival Script
Python has a strong showing in this GMail utility list but where is PHP? Right here. Someone developed the idea of using GMail as a storage service and developed a PHP script to implement the system. It is primitive at this point. Just waiting for someone like you to come along and build upon the foundation provided. Are you up to the challenge? Also, a modification was added by Tys von Gaza to allow the PHP script to return the number of new messages in a GMail Inbox. Scripting Language: PHP PHP source file ( PHP source, with new message counter ( Source: iBlog - Ilia Alshanetsky...

here is an example for the new mail extension I wrote, it is a simpler to show an example for. If you are having trouble with these concepts I suggest you goto http://www.php.net/ and start with some basic tutorials. Best way to learn is to do those, make mistakes and learn from your mistakes.

---
Edit the line in:
http://tvg.ca/files/gmail.phps
That reads:
echo gmail_check_mail('login','pass');

Replace the 'login' with your gmail login name (keep the quotes), and 'pass' with your gmail password (again keep the quotes).

I'm sure the GMail folks are going to love this.
Aren't you sure you're not going to get your account closed for violation of the service agreement?
Maybe GMail is reliable as a storage, but if there is a risk they can close your account, I'd think it's not that safe, as a backup

Paul, nice comment spam! I looked at that site and saw that the smallest pricing package is $166/month for 5GB of space. That competes really well with GMail, even if you throw in $5/month for a cheap PHP web host to the GMail cost.

I was wondering if you guys have a JavaScript version of the script. I'm trying to collect all sorts of login forms (gmail, hotmail, etc.) onto 1 HTML page and use that as my start page. But I don't know to achieve the same effect as this php script with JavaScript.

There is actually a very very cool program that lets you POP and SMTP your Gmail ... works with any POP reader, but the client in windows only for now, i think ...
Read about it here ...
http://www.livejournal.com/users/vinit/10974.html

Excellent little functions. I have also added another 2 functions to the list (I'll throw out a link to it later).

function gmail_get_attachments
and
function DownloadAttachment

Basically, what the first function does is retrieve all the available attachments that we have backed up, and lists them on a page as clickable links. Once you click on the link, it retrieves the file, and it pops up the "Save/Open" dialog box in your browser.

I'm am traying to get a Gmail account. Since I have read all the benefits that it allows you to have, and if an action needs to exist for an answer I definitely would be at your service in all the ways that I could be able to help.

Hey,
I was working on something identical to this using CURL, when I decided just to google the idea first, and of course its been done.. a couple months ago I did something similiar (not as cool or usefull) that lets you use google's image search to find an image based on keywords, then display that as an image, so you could do: and it would give you the i'm feeling lucky match for a boat, which is really useful for dynamic pages when you're too lazy to find an image, I'll post code later.. also working on front end for this.

This idea may be expanded to Yahoo (100MB free box) and to MSN (250 MB free box in nearest time).
Of course, I don't recommend use it as full backup, but for specific files backup.
Let's say You are working for important project. You will not burn every day CD for 10 - 100K files.
Other example, use it as common workspace for group work.
If somebody can write more widely used than PHP tool?

Just to note, back on Aug 7 or so, Google changed a few things dealing with the login process, so this script is now broken. I think I have it mostly updated now, I just need to do some more testing to ensure that everything works according to plan. Once done, I'll post a link to the source.

hey i got a gmail invitation from my friend but some how i cannot activate the site it gave me... everytime i click it, after it loads it either says page cannot be displayed or it directs to incredifind... does this mean the site it gave is fake or does that mean theres somethign with gmails database and stuff... or is there something i have to do before using the invitation.. or is there some buttons or requirements i have to have... please reply

Can anyone tell me what I need to do so I can get my backup script sent via email attachment to my gmail account. I can't seem to get my script attached to my horse so it can buggy it over to my gmail account that I would like to use for storing backups.

LOOK AT WHAT this "thread" (i think it is called that) has turned into : a support site for Gmail/where to beg for a gmail account...The last six messages don't even have anything to do with the original topic! :-l..meh

Its been a few months since I heard of google's intention to launch a free email account with 1 GB capacity.... unlike the 2 mb/ 4mb provided by other sites, since i need to be shuttling between places and would not be able to access my work email-id always , a copy of mails marked to gamil account with 1GB capacity could be very useful in accessing information from wherever i am and would also a source of back up whenever my work place mail server is down
but unable to find in google site....how do i register for a gmail account and get one?

Its been a few months since I heard of google's intention to launch a free email account with 1 GB capacity.... unlike the 2 mb/ 4mb provided by other sites, since i need to be shuttling between places and would not be able to access my work email-id always , a copy of mails marked to gamil account with 1GB capacity could be very useful in accessing information from wherever i am and would also a source of back up whenever my work place mail server is down
but unable to find in google site....how do i register for a gmail account and get one?

Well, I am a total newbie...
I have a gmail account and I tried your method to gmail into an online backup. Uploaded the php file after inserting the login name and password. When I open it from my server, nothing happens! Its a blank sheet in the browser. What do I do? I have no idea about php and how to use it in this script. BTW, my server is php enabled.
Please help me.

ANYONE can get gmail invites, all you have to do is use it. Upload a 10MB file to your account, send it as an attachment to a few people, hey presto when you click on the inbox link you'll see a 'invite 6 people' message.
Send yourself one, give the rest away, you can do this as many times as you want.
You'll get invites out of your ears.
In fact here's one: https://gmail.google.com/gmail/a-69f8dc60a6-72fb24fa33-b676eb70af

It's no big deal giving them away, mine was free, so here's one to someone else

Gfile beta 1 is here! Upload/Download/Delete and view date/size on this very basic file manger for gmail. URL: http://jossscholten.com/projects/gmail_083104/gfile/default.php or use the link besides my name. Source available soon.

This was a great thread started by ilia. Thank you for your putting in the time to offer this script. I am sorry that this thread turned into people begging for a gmail account. It is amazing that people are still asking for an account even though there were about three different ways listed to get one. Thank you again for everyone that has worked on this script.

Check out Joss's great work at the following site. If your server is PHP enabled all you have to do is copy the source code and add a folder named "temp" to the place you copied the source files. Strip out the everything but "styles.css" from the link lines in default.php and main.php to get a nice table layout.

Yes, they're is a 2meg upload limit on my server that I haven't had a chance to figure out how to change.. its in the php.ini or something. Gmail has a limit of 10 megs. I'll fix it soon.. GFile 1.0 with massive upgrade of features and such will be out soon. If you need to upload the files, you can just email them to your account for now.. Sorry for the issue.

2mb upload limit fixed, now up to 10 megs - same as max you can put on gmail. Currently putting it under redsign (kind of) adding new features (rename, properties, etc.) Should be out sometime in the week.

Joss does then your package included a custom PHP.ini? My webhosting provider said I'd need on php.ini in the directory of the other files but became hiddeously vague after that. I'll go grab your files now

So your pacage overcomes the two meg limit, or do I get to toy with php.ini some more?

Perhaps in a much more future version there could be a feature to 'chunck' files over N megs using either a standard arcive package so the user could unpack the spanned volume himself, or using some other method that required intervention of GFile to recompose on the fly on download.

N could either be the maximum file size for Gmail OR the current webhost/PHP imposed maxfile size.

I'll post a sample php.ini later for you all, you only need to change 3 lines, and possibly 1 line in your httpd.conf or .htaccess. If you look at the readme, working on a routine to split and combine files on upload/download is one of my goals. This probably won't be in 1.0 release but it will come soon. 1.0 should be out later this week. Cheers.

Warning: move_uploaded_file(temp/Eternity.txt): failed to open stream: Permission denied in /home/virtual/site5/fst/var/www/html/gmail/main.php on line 54

Warning: move_uploaded_file(): Unable to move '/tmp/phprY9DYr' to 'temp/Eternity.txt' in /home/virtual/site5/fst/var/www/html/gmail/main.php on line 54

Warning: Cannot modify header information - headers already sent by (output started at /home/virtual/site5/fst/var/www/html/gmail/main.php:54) in /home/virtual/site5/fst/var/www/html/gmail/main.php on line 60

I was able to upload using the one on your site, but if I try and download from mine, I get this error:

Warning: fopen(temp/invites.txt): failed to open stream: Permission denied in /home/virtual/site5/fst/var/www/html/gmail/libgmailer.php on line 340
Could not download attachment

What does this mean? I may not have CURL installed, I don't know how I would go about fixing that either. Could someone please be so kind as to help me? Email me please!

@ Joss
Thank you so much so this. I sorted out the fun issues my my local php.ini and now I'm in the 10meg max club, too Since I'm wishing for features might a much more future version have an upload progress indicator?

Having seen yours, and reasserting the little knowledge I do have, I think the [PHP] at the top is wholly not needed. Can you briefly sketch the diff between post_ and upload_max? If not no worries. Your php package is a joy! thanks again

1. Download zip.
2. Extract and Upload to server that supports PHP and has the cURL library installed (most that have php will)
3. Goto the site, run, it should work
4. You may need to modify the php.ini file if you want to have bigger upload limits, theres also a sample one of those in there..

Update: Just to make sure you don't think I've run off on the project, i'm adding some final touches to the next release. It won't include unicode support yet, but look for it soon. The new release includes an upgraded gui, the ability to rename as well as view properties. The css is better, and supports firefox a heck of a lot better (sorry for that to all you all who had to suffer through uncentered div's).. I'm having a couple small issues with some error checking, and school work -- should be released on Friday evening (cst)

Hurrah! It's here. No it doens't have all the features everyone wanted yet, (including that progress bar for uploads, which is impossibly to do in just php - so i'm not ready to add it and then support everyone's questions yet). It has an improved GUI, bigger work area, better css, properties, rename, delete, etc. The original is still available there if you don't like the new one... tell me what you think.. It's reall late (or breakfast time depending on how you look at it), so I'll post source and updated readme later.

Yes, there is definitely a bug with it and Firefox 1.0 which makes it completely unusable. You can not click the Browse or submit buttons. I have traced it down to the CSS used for the DIVs. Removing all CSS to do with #title, #upload, and #login does away with the clicky problem, but ofcourse then everything is out of line.

I will see if I can figure out exactly what is causing the problem and submit a fix.

Furture analysis is reveals that the CSS layout of #refresh is layed over the top of #upload. From what I can see, Mozilla is behaving properly (since you are using absolute position with 100% width on both).
The easiest fix is to change this

php.ini was never included in the zip.. php.txt IS included in the zip, which you need to rename php.ini (gmail doesn't like .ini's on their servers)
Thanks for your suggestions... I'll look into them.. FF is weird with the submit and browse buttons.. I'll try and fix them.. What do you mean by file deletion options? If gfile still continues to be useful in the future, I'll add a pseudo-folder system using labels to organize files better, as well as a search to find files. Having it upload a thumbnails a good idea.. the script sizes the image now, if you notice you can have the display.php set height and width parameters.. but I'll see about that in the future... As for limiting login permissions, you sound smart, you can add that yourself .. all it takes is an if statement.. But I'll consider adding that in the future..If you have anything else, feel free to email me.

PHP GMAIL DRIVE
Did you see PHP Gmail Drive released under LGPL which shows how Gmail could be an archive. TO download you can go pgd.sourceforge.net and you can see demo on www.rahat-ayub.com/pgd/pgd_0_2_1/
There are some big sized PDF and MP3 files..you can download from Gmail account but exactly same way you do in a FTP server.

For those that are looking programs for using Gmail as online storage, check out Vombato Mail Drive (http://www.vombato.com/) which now has GMail support. It also allows you to use any of your POP3 email server the same way.