I’ve set up a couple of zenphoto installations for my wife. No problems there, even tweaked a thing or two for our liking.
In the process I found out I really like a couple of things about zenphoto and want to use it to replace my Photobucket account. Now the way I use my Photobucket account is what’s important. The only way I use it is to email photo’s to my Photobucket account from my phone (you setup an inbound email address @photobucket.com in your photobucket settings), and have them show up online shortly thereafter.
I’m posting this here rather than the zenphoto forum because the answer really deals more with a script that will probably be more localized to dreamhost than the universal answer for zenphoto.
For those that are not familiar with zenphoto, all that needs to happen to get a photo imported into zenphoto is for the jpg gif etc to get moved into /{DOMAIN}/zenphoto/albums/ (or any sub-directory underneath it). We send photo’s there directly via ftp… works great…. lasts a long time….
(PS – If you want to try this at home you will have to download and install your own zenphoto, the ’one click’ install doesn’t seem to give you access to the /albums/ directory… or it least it didn’t a year ago when I last messed with the ‘one click’ install.)
I poked around today in the dreamhost panel and found how to set up an email filter to send mail from a real internet email address on the mail server to a shell user. I set up a test and can find my email in /home/{USER}/Maildir/new/ but of course the issue is extracting the file(s) from the encoded email and moving it to the proper directory….
What sounds logical to me in this case is a bash script (written in pseudocode below because the syntax etc is what I need help with) called by cron every 5 minutes that:
((sorry in advance… i can’t figure out how to indent the code below in this forum–space / tab neither one stays in place…))
((assume the mail filter set in the panel only forwards mail FROM a specific address (I.E. my phone)… not perfect security but it works for me))
basepath = “/home/{USER}/{DOMAIN}/zenphoto/albums/”
count = “0”
While mailfile exists in /home/{USER}/Maildir/new/
do
Set picfolder BASEPATH “/mobile/” ;the default location
If Subject = “sub_path_that_exists” then set picfolder = BASEPATH “subpath_that_exists” ; or it stays in the default
While another_attachment_exists in mailfile
do
Decode attachment and move to picfolder
Count = count 1
done
If count = 0 forward mailfile to “TO:my_real_internet_email@domain.com?Subject : ‘Pic script failure’ Subject
Remove mailfile from /home/{USER}/Maildir/new/
; cleanup; ; if no files were decocoded then
;we forwarded it elsewhere
;if files were decoded ok then all must have been ok
;so trash the original. Or maybe write it somewhere else for
;debugging
done
If someone could give me a hand coding this I would really appreciate it…. I haven’t done any serious bash scripting since the early 90’s
I’m not stuck on doing it this way either. If someone knows something easier, better, etc by all means…suggest!.. Also if someone just knows something I should go read or study…. point me there… and I’ll go learn from it and carry on…. I Googled around for examples today and could find plenty for sending mail from a bash script, but nothing really at all for processing inbound mail to the shell.
Thanks in Advance!