Postie and Moblogging


Since I have been bitten with the blogging bug, I have found that ideas for post don’t always come when I am conveniently located at a computer. Many ideas hit me during my 60-mile commute to work or on the return trip home. Ideas also seem to magically appear during some of the most regular parts of my day. So what’s an aspiring blogger to do?

Enter Postie, a WordPress plugin that allows you to create and submit a posting to your blog pretty much regardless of where you are provided that you have some type of connection to email or webmail via PDA, cell phone, etc. Postie is an evolution of a plugin originally created by John Blade but had gone dormant. I find that this is the case with so many good WP plugins assumably because either the creators need was met and they simply released their work to the public or because the plugin literally assumes a life of its own and the creator either lacked the knowledge, skill or willingness to manage and maintain a software development project. Regardless of the whys or hows, one of the beautiful things about the Open Source Movement is that where there is a well-defined need or desire there is generally someone willing and able to pick up the cause where others have left off.

Fortunately for me and for others Dirk Elmendorf decided to continue from where John left off and the result has been further evolution of a what looked to be a pretty good plugin.

The premise is pretty simple. What if someone were able to post to their blog from whereever they were whenever they wanted via email using the device of their choosing while being able to include images and attachments while controling a number of the variables required to make posting easy, convenient and requiring little, if any, editing after the post was made. To that end, I think Dirk has himself a pretty solid plugin that does what it perports to with very little challenge in the set-up and ongoing maintenance.

To explain how it works lets start with the end result and work backwards from there. Below is a post that I created on my Motorola Q and posted from the convenience of my living room:

test

snow20907.jpg

test

As you can see, my test was pretty simple but very demonstrative of the true possibilities that Postie brings to the table. Now, truth-be-told, this entire post was originally created using Postie, I just decided to add in some commentary around the actual posting itself. Using the plugin, you can control posting variables such as the title, the category it is posted to, images and attachments and when it is posted. I won’t go into all of the details of the variables (as I think Dirk covers those pretty well), but I will say that they offer pretty limitless possibilities.

The biggest challenge for me (and many others it seems) is getting the back-end processing working. The true magic of Postie is the fact that if it is installed and configured properly it really takes care of itself. What I mean by that is the fact that through some server-side magic, Postie checks a designated (and hopefully very secret) email account on a pre-determined interval and posts the contents of those emails to your blog. What allows this transaction to take place is a cron job, a program that enables unix users to execute commands or scripts (groups of commands) automatically at a specified time/date.

There are two ways to do it: via plugins such as WP-Cron, a plugin that provides rudimentary support for scheduled exection of actions; a sort of “delayed action” processing for WordPress. According to the author: “It is nowhere near as robust as the actual UNIX cron facility, but should be good enough to “do stuff” on a fairly regular basis”. My other option was to run the cron via the shell from the command line.

Admittedly, I am a Linux newbie and it took me quite some time to understand how all of this worked. I initially took the path of least resistance (plugin) but quickly found that it wasn’t yielding the desired result and instead of simplicity, I got complication. Since the cron job is supposed to run at fixed intervals all I would theorhetically have to do is install the Postie plugin and the WP-Cron plugin, send an email posting the wait 15-minutes or so and voila, my post would appear nicely formatted and ready for public consumption. However, what I found was that the two plugins didn’t necessarily play as nicely as I had hoped. I don’t think this is a failing of either plugin but rather attribute it to the fact that I wasn’t entirely sure (a) if they were even meant to play nicely with each other and more importantly how the process was “supposed” to work. Just as a point of clarification, the WP-Cron did allow Postie to work it’s magic, but I seemed to lose most of my post formatting along the way.

This caused me to bite the bullet and look at doing it the “old-fashioned way”.

Since I am hosted by Dreamhost (who I highly recommend as a host if you are in the market) I have the ability to run cron jobs from the shell. At DreamHost, they servers they uses to host your website all run the unix-like operating system known as Linux (specifically, Debian Linux). Some of their hosting plans allow you to get a “shell account” on the server, which allows you to access unix commands. “Although it can be intimidating at first, learning even just a little bit of how unix works can really help make your hosting experience a better one!” The quote is taken directly from their Wiki, and while I may have disagreed when I started yesterday afternoon, now that I have overcome the learning curve, I couldn’t agree more.

Granted, I had to download PuTTY, a free implementation of Telnet and SSH for Win32 and Unix platforms, along with an xterm terminal emulator, figure out how it worked and what I needed to do to create a cron job, and it was pretty overwhelming. Thankfully, the combination of searching on Google, the Postie website, the Dreamhost Wiki, and the Dreamhost Forums along with some time and patience allowed me to get up and running with minimal frustration.

My biggest challenge wasn’t learning all that I didn’t know (Once you get a handle on the language used to explain everything and the commands required to use PuTTY it was pretty easy) or creating the cron itself (again a matter of using the right commands and syntax) but really resulted from how Dreamhost has their servers configured. The secret to this cron was finding the right path to PHP on the server and then pointing to the script that I wanted to run. I tried numerous iterations without success and then finally struck gold earlier today.

I had been trying the following:

*/10 * * * * /usr/bin/local/php /home/username/path/to/file/to/execute

which continously resulted in a file not found error. For the life of me, I cannot understand why it didn’t work. That increased both my frustration and resolve. I continued searching to see if anyone else had a suggestion and came across this solution:

*/10 * * * * curl http://mydomain.com/path/to/file/to/execute

Again, since I am a relative newbie, I didn’t understand the premise of cURL but after some research I learned that the main purpose and use of the cURL command line tool is to automate unattended file transfers or sequences of operations. It is, for example, a good tool for simulating a user’s actions at a web browser. With that understanding and seeing that my cron was running appropriately, I felt like I was finally off and running.

Now everything is running as it should and I feel like I could leave it alone, but I have yet to research what, if any, deleterious effects using this approach as opposed to the former may have. Likely I will keep experimenting to see if there is a better, or more efficient way to run my cron job. One potential idea that I came across on the Postie website, but have yet to try, may address my concern and open up some additional functionality included within postie. It seems that a user by the name of lipilee suggested that by creating the cron using the cURL command in the following manner:

curl -c [cookie file] -d log=[username] -d pwd=[password] http://[your blog’s address]/wp-login.php
now you stored the cookie WP gives you upon login. let’s use it:
curl -s -b [cookie file] http://[your blog’s address]/wp-content/plugins/postie/get_mail.php >>/dev/null

That curl will use the cookie from the file and it will run the get_mail.php script just as if you logged in before. This could be attractive as it causes the blog to think you are actually logged-in and adds additional code not present if you aren’t. It’s been quite the learning experience for me but the upside is the fact that I now have the ability to blog from just about anywhere and I also learned quite a bit about working from the command line. All in all, I would say it was totally worthwhile.

Information and Links

Join the fray by commenting, tracking what others have to say, or linking to it from your blog.


Location
Home (Allentown, PA)
Share and Enjoy These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Netvouz
  • StumbleUpon
  • BlinkList
  • blogmarks
  • DZone
  • ThisNext
  • MisterWong
  • Wists
Other Posts
Valentines Day Blizzard?
First Measurable Snow of the Winter

Reader Comments

[…] Dave Sabol’s Experience […]