Those pics up on top of my front page? They’re pictures from my 3G phone, sent
in an MMS to an email address which pipes them to this here
perl script wot I wrote which creates MT entries and thumbnails
Notes about usage and development:
- Firstly, have some idea how to configure a script and have incoming
mail piped to it. (I’m assuming basic UNIXy knowledge here) You’ll
also need a working MT install and, somewhere reachable, the MIME::Tools
modules. Oh, and obviously this should all be
done on the same machine. (i.e. the machine that publishes your blog
should also be capable of receiving email) (UPDATE: If you have blog and email on separate machines, Ben Milleare’s POP3 version may be the thing for you)
- Download the script and set the variables at the start. You’ll
also need to make a directory for the unpacked MIME files to go into.
- You may want to make a new MT category for pictures, which makes it
much easier to do tricks like my picture bar. The code for it looks like this:
<MTEntries lastn="4" category="pic">
… since it’s the entry excerpt that holds the clickable thumbnail.
Once you’ve made the category, put its ID number into the $CAT_ID constant
at the top of the code. If you don’t want to use category-setting, set it to 0.
(Oh, and you’ll want to edit your main
the Main Index to use every category except the picture one.)
- Unfortunately, there aren’t currently any logging or
debugging facilities for the script beyond those that your MTA or
perl environment provide. However, I found that testing by piping
a pre-saved mail from a file was enormously helpful. (Well, more
helpful than having to work my way through my phone’s abysmal
message-sending interface and then sifting through the mail logs
for errors every time, anyway)
- Once you’re sure it works, set up your mail handling in procmail
or whatever. Since I use qmail
(for reasons beyond my control) I have a .qmail-... file
that merely contains the line
There should probably be a preline in there, but it seems
to work fine without it.
- I say above that it’s built for handling MMS (Multimedia Message
Service) mails from phones and the like, but it’ll handle any mail with
an image attachment. (As long as there’s only one image. I should probably
fix that.) If there’s some
text in the body (not the subject) it’ll handle that too, using
it as a title for the entry, the A tag and the value of the ALT attribute.
- Thanks to Chris Carline, the subject line can be used to rotate the image if your phone can’t do that for you.
Send “t” to rotate 90 degrees anti-clockwise or “tc” for 90 degrees clockwise.
- Yes, okay, it’s a badly-hacked-up piece of shite, but it appears
to work. I didn’t use XML-RPC or any of that nonsense because firstly
it seemed a terribly roundabout way of getting some perl to call some
other perl and secondly because I wanted it to do some thumbnailing
and stuff. And okay, when I had this script half-written
me a Python one that was already done but I was too far into this one
to care, and besides, that one didn’t do thumbnailing. Credit must
go to Olivier
Mueller’s script for inspiration
and also to Azeem for
irritating me into thinking about this in the first place.
- Thus, there is no license and no guarantee. Caveat haxxor. If it
breaks in half, you own both pieces. Please don’t use it to kill
people, though mortal embarrassment is fine (and, frankly, inevitable).