skip to content

An updated version of Nick Gerakines' mail2rss.pl

A little over a month ago, Nick Gerakines posted a Perl script to be called from a Procmail configuration file. It seemed to work pretty well, but the anal-retentive cataloger/standards geek in me decided to pass the results through a feed validator. It failed in a few key areas: missing version attribute in the rss tag, improper guid and link tags, and a pubDate with a non-RFC822 date. These all seemed pretty easy to fix, so I went ahead and made some changes. My fixes are a bit inelegant, but they create valid RSS 2.0.

It was pretty trivial to add an RSS version number and to fix the guid error; the latter just required adding the isPermaLink="false" attribute to that tag. However, Nick's original code required parsing the pubDate tags to determine when to kill data that was over 6 hours old. I didn't want to be bothered parsing an RFC822 date with this, so I moved that information into a category tag. The RFC822 date code was simple to extract from this code snippet. The link error was fixed by pulling out the Message-ID header from the message and converting that into a mid: URI. Obviously, if you click the link in an aggregator, you'll get an error or some sort of other unideal behavior, but this could be tweaked further.

I'd really like to switch this to an Atom 1.0 feed instead, so that and adding to the top of the stack (reverse-chronologically) are the next things to work on with this. My perl-fu isn't the greatest, so things could be better, and obviously the typical caveats regarding security and all that go into play. It's a fun toy, though, so as long as you're careful I'd assume that you have not much to worry about.

Comments