Support forums : Quickies

upload photos by email

A home for really quick one-liner thoughts about what we need to fix or do or whatever. If they spark discussion we move it, otherwise this is like post-it notes.

Moderator: Dracones

upload photos by email

Postby Kimberly » Thu Aug 02, 2012 8:08 pm

The client wants people to be able to upload photos to their site from their phones. My thought is that I know nothing about phone apps and I don't really want to go there at this time. So my idea is for the users to upload the photos by sending an email.

Now we have blog by email so some of the framework is in place. Of course blog by email requires a user account and I don't really want to create a blog post just allow QP to check the email account and download the attached images to the media folder. So I am guessing a plugin with a cron job to check the email account every xx minutes, get the emails, extract the attachments and drop them in the media folder and then request the email to be deleted from the server.
Kimberly
Dracone
User avatar
 
Posts: 842
Joined: Mon Jul 19, 2010 4:44 pm

Re: upload photos by email

Postby leeturner » Thu Aug 02, 2012 8:22 pm

Sounds like that would be a good way to go.
leeturner
Dracone
User avatar
 
Posts: 730
Joined: Fri Dec 11, 2009 11:55 am
Location: Brighton, UK

Re: upload photos by email

Postby Kimberly » Fri Aug 03, 2012 5:44 am

If I could get the script to connect to the mail server. Using PHP imap_connect() but I get some error about a certificate mismatch. I contacted the host to see if they could decrypt the message I got.
Kimberly
Dracone
User avatar
 
Posts: 842
Joined: Mon Jul 19, 2010 4:44 pm

Re: upload photos by email

Postby EdB » Fri Aug 03, 2012 7:57 am

You might want to look at http://www.phpclasses.org/package/6604- ... sages.html and see if it offers any value
EdB
Dracone
User avatar
 
Posts: 2072
Joined: Sun Nov 22, 2009 7:20 am
Location: Maricopa Arizona

Re: upload photos by email

Postby Kimberly » Fri Aug 03, 2012 5:02 pm

I meant to type, imap_open(). I set up blog by email and tested things using the backend and was able to make a connection. Of course blog by post failed since I am not including the login/password in the email. However, that shows that getmail.php is working and it retrieves the emails by imap_open(). getmail.php retrieves the settings from the database so creates the imap_open() string on the fly. I may go into getmail.php and add some outputs to show me what it created so I can match that to my code in my script.

Thanks for that link, on my way there now.
Kimberly
Dracone
User avatar
 
Posts: 842
Joined: Mon Jul 19, 2010 4:44 pm

Re: upload photos by email

Postby Kimberly » Fri Aug 03, 2012 7:06 pm

I had getmail.php to echo out the mail server settings since it was able to connect to the server. I had everything the same except for /notls switch which is "do not do start-TLS to encrypt the session, even with servers that support it".

The problem now is that I have to wait because it is blocking me with "too many login attempts failure"
Kimberly
Dracone
User avatar
 
Posts: 842
Joined: Mon Jul 19, 2010 4:44 pm

Re: upload photos by email

Postby Kimberly » Sun Aug 05, 2012 8:26 am

I can connect to the mail server and retrieve the contents of the inbox and save the attachments out to a folder on the server. I wanted to automatically add a suffix to the file name if the same file name was on the server. The way the script operates makes that a little difficult to simply index the number so for now while solving that problem I just add a random number as the suffix; really doesn't matter what the suffix is as long as I can retrieve two attachments with the same name since two different people might send me a file with the same name but different content. However, I don't want to stop there. I want to send the images to class.upload.php for post processing and then save out to a directory with the name of the current month and year; if that directory (OK, mixing folders and directories, such is the life of multiple OSes) does not exist then create it. The snag I hit with creating the folder was a permissions error but I got around that using ftp_mkdir() instead of mkdir(). Of course the ftp account will be one just for this so if by some chance someone gains access to the credentials they won't have anything but the temp folder for the attachments as the files will be move to the media folder immediately after post processing.

So, almost there. Of course this is a stand-alone script for now but there is no reason why it couldn't be turned into a plugin to allow a QP user the ability to have non-users email files to the server. This is done on some of the photo sites where you can email your photos to your gallery and they automatically appear on your site. Of course our blog-by-email feature is close to this but it does not do the post processing of the images and one has to add the user:password in the email. What I am doing does not require any special subject and the body of the email can be completely blank as it is just ignored.
Kimberly
Dracone
User avatar
 
Posts: 842
Joined: Mon Jul 19, 2010 4:44 pm

Re: upload photos by email

Postby Kimberly » Wed Aug 08, 2012 7:14 pm

There was no need of me to write a routine to make the directory, class.upload.php can do this automatically. All I had to do was to generate the name of the directory using date().
Kimberly
Dracone
User avatar
 
Posts: 842
Joined: Mon Jul 19, 2010 4:44 pm

Re: upload photos by email

Postby leeturner » Fri Aug 10, 2012 1:31 pm

Seems like it is all going pretty well. You will have to let us have a look at the site when it is finished.
leeturner
Dracone
User avatar
 
Posts: 730
Joined: Fri Dec 11, 2009 11:55 am
Location: Brighton, UK


Return to Quickies

Who is online

Users browsing this forum: No registered users and 1 guest

cron