using procmail and MIME::Parser to extract iphone photo attachments
I have an iPhone. I'm finding myself very prone to snapping photos now, whereas before I was completely unlikely to tote a camera. I also discovered that Movable Type works just fine on the iPhone, I even posted an entry on my personal blog from it while we were at the ice cream place.
But you know what? I want to put up a photo I just blogged. But transferring a photo via anything but email is a pain. Enter perl. I whipped up a perl script to receive iphone photo email, piped via procmail, and save the photo attachment to a path, then email back the phone address with the filename it used. Just make sure you set the path in the script to somewhere down from your DocumentRoot, and then you can immediately reference the photo with an img tag.
Now I can photoblog directly from the phone, which is pretty fun.
sendmail (for the outbound msg, but I bet you could adapt any other mail program)
Here's the relevent part of my procmail entry (note that photoblog is an alias that goes to my user account via /etc/aliases):
:0H * ^TO.*email@example.com |/home/matt/iphotoparse.pl
And the code, which you can get here: iphotoparse.pl
Happy photoblogging from the phone.