Email your blog

I figured out how to set up an email address so you can post to your Blogger API compatible blog via email. This has probably been done before, but I couldn’t find any references for it.

What’s a Blogger API compatible blog? Any blog that supports the Blogger API like Moveable Type, Roller, etc.

My little email to blog bridge runs on Python using the PyBlogger software. To get my code running you’ll need to download PyBlogger and have Python installed. Oh yeah… And you’ll need to be running your own mail server. 🙂 I’m running sendmail on linux.

In the same directory as PyBlogger create a file “” (or whatever):

import sys
import getopt
import Blog

def main():
argv = sys.argv
username = argv[1]
password = argv[2]

line = sys.stdin.readline()
lines = ''
while line != '':
lines = lines + line
line = sys.stdin.readline()

header, body = lines.split('\n\n', 1)

body = body.strip()
body = body.replace('\n\n', '<br><br>')

user = Blog.User(username, password)
blogs = user.blogs

blog = blogs[0]
posts = blog.posts

if __name__ == "__main__":

This could probably be made 50x more elegant… Once you get this code in place, test it out on the command line:

prompt> python username password
Subject: blog entry

Hello, this is a blog entry I would like to put in my blog.

To enable the email to blog linkage, go into your .forward file (or in /etc/aliases if you’re clever) and put the following:

roseblog, "|/usr/bin/python /private/pyblogger/ rose password"

Replace the parameters with the values that make sense for your environment.

If you want to not post to–you want to post to your own blog server–edit the file in the PyBlogger source and change “xmlrpcService” to point to the XMLRPC interface for your blog server.

If sendmail is not configured to trust python, add a symbolic link to python from the /etc/smrsh directory:

ln -s /usr/bin/python /etc/smrsh/python

If you have any issues be sure to look in /var/log/maillog for errors.

Leave a Reply