slash2mail: a slashdot to email gateway


Download

slash2mail.pl

What:

slash2mail is a slashdot-to-email gateway that polls the slashdot webpage every few hours, and mails out new stories and (optionally) score5 comments, all nicely mail-threaded.

This picture is worth 163 words, exactly

[screenshot of xterm containing 163 words, doh!]
That mail ends with
   ...
   of something, whether it be my employer or a competitor. Happy?? _

> References

   1. mailto:stiletto_NO@SPAM_.mediaone.net
   2. http://slashdot.org/users.pl?op=userinfo&nick=Stiletto
   3. http://www.pompano.net/~stiletto
this. http://slashdot.org/article.pl?sid=00.05.29.141259&mode=thread&threshold=5#127

Why:

for a number of reasons.

Why not:


Caveats:


Observed traffic:

Moderately high. About 15 stories in one day (today), and about 60 score5 comments. I tell myself that I'd be reading all these anyway, only more painfully via the web. And you can turn off comments if you feel 75 mails a day is too much.

Mechanisms:

It runs via a cron job, set to launch every six hours. The common-case overhead is very small - it only needs to fetch a barebones version of the main slashdot page, and perform one pass over it. If there are any new stories or new comments (detected by changes to the m portion of the "m of n comments" thing), it fetches the suitable comments page and extracts all the relevant stuff, and sends mail to the designated recepients. This overhead is typically a few seconds.

It generates suitable Message-ID and In-Reply-To headers, so that comments thread as expected. This has a side-effect: the script has to run sendmail on the local machine; you cannot use a mail server, as these like to set their own Message-IDs on relayed mails.

There is a timeout of 30 seconds imposed on each slashdot wget; this is in case the site hangs, and a 3-second timeout on each gethostbyname.

It pipes the body of stories and comments through lynx -dump, so as to generate a `References' list of urls. The ">" at the beginning of the Author and References lines is for the mutt pager: skip-quoted while viewing the mail jumps over to the body, which I find convenient.


Installation:

You'll need perl, wget and lynx. This program is one 325-line perl script, hacked up in one afternoon. It uses the Mail::Sendmail and the MIME::Base64 CPAN modules; you can download them from www.cpan.org. It uses a DBM file ~/.slashdot.db to store a history of read stories.

Toss the script into /usr/local/bin or something, and edit it; you might want to change some variables to your liking. In fact, you'll definitely want to edit the recepients line, at least. Then add this line to crontab: (you can edit user crontab files with the command crontab -e):

0 0,6,12,18 * * * /usr/local/bin/slash2mail.pl

That should do it. In the next few hours, you'll get an initial flurry of mail to slurp up everything that's currently on slashdot, then it'll trickle down to one new mail whenever a new story or comment shows up.


TODO:


Licence:

This script is distributed under the BSD license. Since I don't like the license taking up more than half the script, I'll choose to simply link to the general template, and leave the inclusion to whoever cares :) fwiw OWNER="Sitaram Iyer", ORGANIZATION="", YEAR=2000.

FreeBSD note:

The default wget on FreeBSD has one problem: those smart guys decided that the ampersand "&" character is unsafe for general consumption, so they escape it out into "%26". This causes unbelievable problems with GET requests that have CGI arguments. Fixing this involves
$ cd /usr/ports/ftp/wget; mkdir x; mv patches/* x; make && make install

Sitaram Iyer, 01jun2000