I’m thinking about adding mail subscription to Oddmuse. I used to oppose this, claiming that people should use rss2email and similar feed subscriptions as a replacement. I changed my mind when I joined the RPG Bloggers. I read a lot of posts from blogs I’m not subscribed to. When I leave a comment, I’m interested in getting notified of replies to this one post only. Email just works.
Visitors can add their email address and click a checkbox to subscribe to changes when they edit a page. The requirement to successfully edit a page acts as a defense mechanism against spammers and vandals (SoftSecurity).
Email addresses are stored in a file. Each mail contains an unsubscribe link, and from there users can see (and unsubscribe from) all other pages they are subscribed to. The link contains a hash of the email address which prevents others from guessing what email addresses have subscriptions.
There is also an admin interface that shows which email addresses are subscribed to which pages, allowing the easy removal of email addresses from the database.
The problem was that on my host, there is no C compiler, so I was unable to install Email::Sender. The web processes also run in an environment without access to sendmail. Net::SMTP does not support Transport Layer Security (TLS). Googling around I found a “Simple SMTP client with STARTTLS and AUTH support” by Michal Ludvig: Command line SMTP client.
On my Mac OS 10.4 system at home, I wasted a lot of time trying to install Bundle::CPAN. Gaaah! Some dependencies were not automatic, but a few good invocations of
reports on the CPAN command-line followed by manual installation of the missing package did the job.
I also needed to install IO::Socket::SSL with all its dependencies. Yuck! And it turns out that there is a dependency on Net::SSLeay, which needs a C compiler to build.
Thus, the command-line script will also not do for me!
In the end, I think I will ask them to install libemail-send-perl and libnet-smtp-ssl-perl for Email::Send and Net::SMTP::SSL; there is also Email::Send::Gmail but no corresponding Debian package. We’ll see; I might get it to work without.
Anyway, I decided to invest some time into coding an Oddmuse extension. I was all enthusiastic about it. But now I spent hours fooling around with Perl installations and test programs, I think I will stop it now and read a book or something.
Oddmuse Sends No Email
Thinking about it some more, sending mail after an edit might work for comment submission on comment pages, but it will never work for edits to ordinary pages. So right now I’m working on code that lets me subscribe and unsubscribe from pages, and a computer-readable output of said data. Then I will use a cron-job to send the appropriate emails.
I wanted to test my various redirection and forwarding schemes in place…
for m in firstname.lastname@example.org email@example.com firstname.lastname@example.org email@example.com firstname.lastname@example.org; do echo test | mail -s $m $m; done
And a bit later:
|Alex Schroederemail@example.com - test||12:35 pm|
|Alex Schroederfirstname.lastname@example.org - test||12:32 pm|
|Alex Schroederemail@example.com - test||12:31 pm|
|Alex Schroederfirstname.lastname@example.org - test||12:25 pm|
|Alex Schroederemail@example.com - test||12:25 pm|
I sent this from a FSF account, and surprisingly the mails that had to round trip via Europe took several minutes longer. Somehow I’ve gotten used to the idea that geographical distance is no longer relevant. Internet distance is measured in bandwidth and data congestion, not in kilometers travelled.
I use Gmail for my private emails. Google’s spam filter was the easiest to use (no setup required) and worked the best. You can also fetch mail from other accounts using POP3. This feature doesn’t really work for me. Every month or so I discover that my Emails are not being fetched. What is going on?
Looking at Gmail → Settings → Accounts → View history:
|Sat, Jun 23, 2007 at 7:37 PM||200 mails fetched. 2357 mails remaining.|
|Sat, Jun 9, 2007 at 10:26 AM||No mails fetched.|
|Sat, Jun 9, 2007 at 10:17 AM||2 mails fetched.|
|Sat, Jun 9, 2007 at 10:12 AM||One mail fetched.|
|Sat, Jun 9, 2007 at 10:07 AM||2 mails fetched.|
This is useless.
So I contacted ThomasWaldmann who runs thinkmo.de which hosts emacswiki.org, and asked for advice.
We had the following LDAP entry:
dn: firstname.lastname@example.org,ou=Mail,dc=thinkmo,dc=de objectClass: mailAccount objectClass: mail mail: email@example.com gidNumber: 20008 uidNumber: 20008 mailDirectory: /srv/org.emacswiki/mail/alex/ homeDirectory: /srv/org.emacswiki/mail/alex/
We replaced it with the following:
dn: firstname.lastname@example.org,ou=Mail,dc=thinkmo,dc=de objectClass: mailAlias objectClass: mail mail: email@example.com mailDrop: firstname.lastname@example.org
I then got a 10MB tarball of
/srv/org.emacswiki/mail/alex/ including a directory call ‘cur’ containing what looks to be one file per Email. What would be the easiest way to read them? I’d love to import them into ThunderBird and use my existing spam-filters on them.
Well, first things first. I knew that the subject line of these mails contained the string
***SPAM*** so I unpacked the tarball, changed into the directory with all the files and ran this little command:
for f in `grep -lF "***SPAM***" *`; do rm "$f"; done
-l prints only the file names that match and
-F treats the pattern as a fixed string instead of a regular expression.
That reduced the number of candidates to 161.
I tried using Emacs! I knew that Gnus could read and write Email in various formats. So here we go. Start Emacs. Run
M-x gnus. Answer ‘y’ to
Unable to open nntp:news, go offline? (y or n) and answer ‘y’ to
nntp (news) open error: ''. Continue? (y or n) – I don’t care about news right now.
I must have some Gnus data lying around. My
*Group* buffer listed two groups:
BACKUP. I have no idea. The last messages are from 2006-05-17. I guess I don’t need them anymore. Use ‘c’ to “catch up”.
Now, I need to create a group that uses my directory as a source…
gnus-group-make-directory-group looks like a good candidate: “The user will be prompted for a directory. The contents of this directory will be used as a newsgroup. The directory should contain mail messages or news articles in files that have numeric names.”
Damn the numeric names!
Group nndir:/Users/alex/Documents/Mail/alex/cur contains no messages.
I wrote a little script called
#!/bin/sh NUM=1 for f in "$@"; do echo mv "$f" $NUM (( NUM++ )) done
number-files * was looking good, so I called
number-files * | sh. I like double-checking my commands. (As Pierre noted in the comments, this breaks if the filenames contain spaces!)
I got 161 files named “1” to “161”. Still looking good!
Back to Gnus and ‘G d’ to create that directory group.
Hah! It worked!
Now to export it to mbox format…
- Use ‘M P a’ to mark all articles with the process mark.
- Use ‘C-o’ to write it to a “Unix mail box file”. Too bad this required me to hit
RET161 times. Next time, I need a command without a confirmation question. Gah!
(Update: A helpful visitor suggested setting
t before using before using ‘C-o’.)
Anyway, I used
~/mbox as the output file, and everything is still looking good. A bit less than 4MB of spam to go.
So, where to I put this?
- Find the Thunderbird directory. On my Mac, it is
- Move the mbox file there. I also renamed it to “Mbox”.
- Start or restart Thunderbird.
- Find your new folder in the “Local Folders” section.
- Use “Apply Junk Filter to the Current Folder” from the “Extras” menu. (I’m translating from German to English, so your menu entry might have a slightly different name.)
Except that now I have to read all the old mail and apologize for my Email problems.
I’m forwarding all my mail to email@example.com and firstname.lastname@example.org to my Gmail account. I realized I didn’t want to start Thunderbird anymore. Having to sift through a dozen spam mails just to find the occasional mail I cared about turned me off. I ended up reading those mails about once a week. No good.