This was much harder than it should be, but I now have automatic digests of my new blog entries being delivered to subscribers to my blog@dankohn.com mailing list. (Sign up at the top right on dankohn.com.) You need to be very comfortable with HTML and somewhat familiar with Unix (editing and copying files) or else find someone who is to help you.
Getting this to work requires setting up mailman in digest mode with semi-automatic web-based subscriptions from my blog, changing MT to use full blog descriptions in RSS, using Aaron Schwartz’s great rss2email.py script, setting up a cron job, a lot of testing, and a little luck.
Some specifics:
Create a mailman (or majordomo) mailing list, disable immediate delivery under non-digest options, set the default to digest under digest options, and set it to send a daily digest. Your web hosting provider should offer you mailing list services.
Change the RSS (Really Simple Syndication) template in Movable Type to use full bodies for each entry, not just excerpts (the first 20 words). This generally entails switching from <$MTEntryExcerpt$> to <$MTEntryBody$>. This way, your full entries will be emailed. You want to have those entries be encoded for xml. (They’re put in CDATA containers, but you don’t need to understand that.)
Although not strictly necessary, I’ll also make a pitch here for creating XHTML compliant websites. Two critical plug-ins to make this possible are Validable and Format Breaks. But even better is the Plugin Manager which installs both of these for you. Once these plugins are installed, the tag you want to use is <$MTEntryBody format_breaks="smart_xhtml_br" convert_breaks="0" validable="1" encode_xml="1"$>. Having compliant RSS should make it readable in more RSS aggregators, but shouldn’t be necessary for this process.
Once you rebuild your site with the new templates, you should be able to see the RSS in your web browser at your equivalent to http://www.dankohn.com/index.rdf. The better test is to use a web-based RSS aggregator to make sure that the RSS is parseable.
I used SOAPclient, and you can see what my RSS looks like parsed.
Now, on your Unix account, install rss2email.py. I used the command “wget http://www.w3.org/2002/09/rss2email/rss2email.tgz“, then “tar -xvzf rss2email.tgz“. It requires a version of Python that’s 2.2 or higher, which my machine didn’t have, so I succeeded in doing the download, configure, make dance (all in my own directory), which hopefully you can skip.
Edit the first 4 lines of the file rss2email.py, as directed, and set the destination email address to your own. Edit channels.txt to include only your own RSS, along the lines of “dankohn http://www.dankohn.com/index.rdf“. Enter “cp seen.dat seen.dat.orig” to keep a copy of the original file. Now, run the script by choosing “./rss2email.py“. You should get one email for each of the 20 entries in your index.rdf RSS file. To test again, enter “rm meta_channel.dat; cp seen.dat.orig seen.dat” and then rerun the script.
Once you’re feeling good about the execution, edit rss2email.py to send to your mailing list (blog@dankohn.com in my case).
Now, make sure cron is working on your machine. Create a text file called temp with the contents “* * * * * echo 'test'“. Enter “crontab temp“. This will add the command to print the word test (and email you the result) every minute until your turn it off. Note that cron doesn’t seem to be working at my webhosting account, so I set up the rss2email script at an entirely different site than where I host my website and mailman. Once you’re sure cron works, create a temp file with the contents “55 23 * * * /home/dan/rss2email/rss2email.py” (you can find your path by typing pwd) and do “crontab temp” again. You can confirm this replaced your previous entry by entering “crontab -l“. This causes rss2email to run every night at 11:55 PM.
Last step is to enable your blog viewers to do a form submit to sign up to your mailing list. The best solution is to imitate the HTML from my site. Note that I highly recommend requiring double opt-in in mailman (where the viewer needs to confirm their interest), so that you eliminate the possibility of inconveniencing people.
Now, all of your blog entries from a day are aggregated into a single message and sent out to your eager subscribers. So, only a few hours after you started, you have a mailing list. Not easy or elegant, but quite powerful. Note you can also have many more blogs emailed by adding entries to the channels.txt script.
Hope that helps others.
Post a Comment