Blogmail
Blogmail is a simple email to blog script written in Python (needs python-2.2 or better and xmlrpclib). Posts are sent to your blog using XML-RPC, so your blog needs to implement the blogger or MT API.
You need something like Procmail to filter your mail and pipe messages from a specific address to the blogmail.py script.
blogmail.py can also poll a POP3 server and process any messages on the server posting them to your blog for you.
Download blogmail.tar.bz2, unzip and save it somewhere convenient as blogmail.py, make sure it is executable. (you might need to right-click and save as).
Usage:
./blogmail.py --help for all the usage
information. You can also edit the script to set defaults.
The body of a message should be in the following format:
XBlogTitle: foo
XBlogPublish: [0|1]
XBlogUsername: mike
XBlogPassword: secret
XBlogid: 1
XBlogUri: http://blog.host.com/mt/mt-xmlrpc.cgi
XBlogAllowComments: [0|1]
XBlogConvertBreaks: [0|1]
XBlogKeywords: foo,baz,bar
XBlogCategories: flob,grob,blurck
<%
Body of your blog here, formatted as you wish, include
any html you want (eg: URI's)
%>
All text between <% and %> is posted as the body of the blog, the XBlog* fields are parsed and sent via XML-RPC. XBlogTitle is the only mandatory XBlog* field.
If the message is a multi-part mime message then the first text/plain section is considered to be the body of the post. the first image/* section will be taken as an image to send to the server. Images are saved in:
images/ddMmmYY/HHMMSS_<filename>
and an image tag (<img src=”…” />) is added to the beginning of the post (style <img /> tags with a float and you can have the body of the post beside and wrapping around the bottom of the image).
Sample message:
Return-Path: <troy@foo.bar>
X-Original-To: troy@localhost
Delivered-To: troy@localhost
Received: from localhost (localhost [127.0.0.1])
by selexin.internal.lan
(Postfix) with ESMTP id 4802E518A
for <troy@localhost>;
Mon, 1 Mar 2004 06:10:17 +1100 (EST)
X-Original-To: troy@[127.0.0.1]
Delivered-To: troy@[127.0.0.1]
Received: (qmail 24604 invoked from network);
29 Feb 2004 20:05:13 +0100
Received: from localhost (127.0.0.1) by localhost
with SMTP; 29 Feb 2004
20:05:13 +0100
Date: Sun, 29 Feb 2004 20:05:01 +0100 (CET)
From: Troy <troy@foo.bar>
To: blog@foo.bar
Subject: Test blog message
Message-ID: <pine.LNX.4.58L0.19460@internal.lan>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
X-Evolution-Source: imap://troy@internal.lan/
Content-Transfer-Encoding: 8bit
XBlogTitle: This is a test post
XBlogPublish: 1
<%
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Quisque tincidunt egestas quam. Nam malesuada, turpis id
accumsan eleifend, libero nisl hendrerit sem, et viverra
felis odio vitae arcu. Suspendisse non ipsum et metus
ultrices aliquet.
%>
--
Troy
<troy @foo.bar>
Sample Procmail recipe:
:0
* ^TO_blog@foo.bar
|~/bin/blogmail.py -f
Download:
Changelog:
Here is the Blogmail Changelog
License:
Use this script how ever you see fit, at your own risk. It was thrown together rather quickly, so there are probably many, many glaring security problems and things that will cause it to explode. Having said that, if you have an improvement, drop me a line: troy@tkdack.com


Entries (RSS)