This weekend I wrote a small Python program to post entries to MovableType via email. I used Mark Pilgrim’s Python wrapper for the Blogger XML-RPC API, PyBlogger, and Mark Lutz’ examples of Python email programming. The ‘mailblog’ pulls mail from a pop3 email address used only for blog posting. The script also works to post to Blogger, but Blogger Pro already has the feature.
Post via email is the one indispensable feature that Blogger has and MT doesn’t
Mailblog lets you address an email post with a friend in the to: field and the blog email address in the bcc: field. Can’t do that with the Blogger feature. This exactly duplicates the intent I have in publishing the blog, which is to share with more people things that I was already writing via private email, without committing spam.
Need to manually trigger the script to pull the email into the CMS. This is not a big drawback. In some ways it’s more convenient than the blogger implementation, which apparently works by polling the mail server ever 5 minutes, so email posts take a while to show up. The “blogmail” script generates the post instantly. I could avoid the manual step by writing a server-side procmail script to instigate the post when the email is received. But first I need to learn procmail.
Pyra hasn’t yet published the API for the title field, so email posts need to be titled manually. MT doesn’t complain.
What I learned:
Mark Pilgrim’s PyBlogger is lovely. Written for other people to read and use, not just for the computer to interpret. The code is clear, the variables are words, and the comments/inline docs are lucid and unambigous. Docs and comments so often contain grammatically correct English sentences with more than one possible logical meaning.
PYTHONPATH. The biggest stumbling block was figuring out how to include files that lived in faraway directories. Mark Lutz’ directions and the PythonWin IDE were unclear. Fortunately for my self-confidence, numerous others have described the topic as confusing, including the esteemed Python guru, Tim Peters. The polite way to do this is add references to the required files in the header of your program, in this manner: sys.path.append(‘C:\\Program Files\Zope\lib\python’).