PHP Email To Upload

Author: Michael Shoup

*Update: This seems to be working fine for images sent from my iPhone, but videos [for those who are Jailbroken] and a few other filetypes have problems. Any suggestions? Working to Fix.

Description

PHP Email To Upload was built as a quick fix for the lack of a robust iPhone application for Dropbox. Basically, I wanted to be able to SEND to my Dropbox from my iPhone, as well as stream the files via the web interface. However, it could be used for a number of different applications.

Basic: You send an email with attachment from your phone to a specified email address. Email To Upload grabs this attachment and uploads it to your Dropbox. This is very much like a Facbook Mobile functionality.

Advanced: Got a Mac sitting around at home that's always on? Send an email from your phone, Email To Upload uploads to your Dropbox, Dropbox syncs with your Mac with an Automator script looking for new files. Maybe your file contains instructions or Applescripting? Maybe a command to play music, or turn on the camera? Possibilities are pretty broad.

Usage Instructions

Two files and a few variables are all that you need to change. Below, grab:

DropboxUploader.php (pick the latest version)

cronMe.php

Change the variables in the head of cronMe.php to fit your situation, like thus:

// SET THESE VARIABLES TO FIT YOUR SITUATION //
///////////////////////////////////////////////
// YOUR DROPBOX INFO HERE
$dropEmail = "username@domain.com";
$dropPass = "password";
// EMAIL TO CHECK HERE
$emailToCheck = "email@domain.com";
$emailPass = "password";
// open POP connection
//GMAIL POP with NO Validate
$inbox = imap_open("{pop.gmail.com:995/pop3/ssl/novalidate-cert}INBOX", $emailToCheck, $emailPass);
//NORMAL POP connection
//$inbox = @imap_open ("{server:110/pop3}", $emailToCheck, $emailPass);
///////////////////////////////////////////////

Next, upload these files to your webserver, and make sure they have permissions set to 775.

Last step is to setup a Cron Job to run the "cronMe.php" script at whatever intervals you want to check for new emails. There may be a more sophisticated way to do this, but my PHP and server knowledge is a bit lacking, so please, feel free to edit and make it better. You could also just view "cronMe.php" in a browser to execute the script for uploads as well, if you need them to be immediate.

Once you done that, you're golden! Send an email with attachment, run the script, there you go!

Extra added fun: You can specify destination directory in the "subject" of the email.

Ex: Public/Mobile or merely Photos

Grab the source code below and hit me up on my website or in the forum if you have questions, comments.

Source of cronMe.php

DropboxUploader - Cheers to Jaka J for this!

My site for questions or comments

DropboxAddons/EmailToUpload (last edited 2009-04-11 15:05:02 by JakaJ1)