Meerkat XML-RPC over SMTP

by Rael Dornfest

Experiments in Meerkat XML-RPC over SMTP using Python and a little hackery; a followup to yesterday's thoughts on the subject.
The script to which an incoming email message containing an XML-RPC request is routed by procmail. Basically a silly proxy between SMTP and Meerkat's XML-RPC server; yes, I could have merged the two, but the latter is written in PHP and it is Sunday after all.


import sys, rfc822, xmlrpclib, smtplib

# Grab the message headers and body
header = rfc822.Message(sys.stdin)
body =

# Decode the XML request, extracting parameters and method
(p, method) = xmlrpclib.loads(body)

# Ick! If you don't know, don't worry about it :-\
params = {}
for pp in p: params.update(pp)

# Instantiate a new XML-RPC Server object
server = xmlrpclib.Server(

# A simple dispatch map of supported methods
methods = {
'meerkat.getItems': server.meerkat.getItems,
'system.listMethods': server.system.listMethods,
'meerkat.getCategories': server.meerkat.getCategories,
'meerkat.getChannels': server.meerkat.getChannels,
'meerkat.getChannelsByCategory': server.meerkat.getChannelsByCategory,
'meerkat.getItems': server.meerkat.getItems

# Reply to the sender with the results of the Meerkat
# XML-RPC method call
'Subject: re:' + header['subject'] + "\n" +
Some minor alterations to the Python xmlrpclib module so as to retrieve a raw XML response from Meerkat's XML-RPC server.

$ diff ../Modules/
< #return self.parse_response(h.getfile())
< return h.getfile()
> return self.parse_response(h.getfile())
< #if len(response) == 1:
< # return response[0]
> if len(response) == 1:
> return response[0]

The Request
An XML-RPC request-laden email message sent to

From Sun Mar 25 21:46:17 2001
Date: Sun, 25 Mar 2001 21:43:56 -0800
From: Rael Dornfest
To: meerkat...
Subject: rpcmail: getItems

<?xml version="1.0"?>

The Response
An XML-RPC response-laden reply to

From meerkat... Sun Mar 25 22:13:14 2001
Date: Sun, 25 Mar 2001 22:09:10 -0800
Subject: re:rpcmail: getItems

<?xml version="1.0"?>


<value><string>Another Python-driven WikiWiki implementation.
[Win32, Unix]</string></value>
<value><string>Vaults of Parnassus</string></value>