Search this site





One anti-spam effort too easily defeated.

I see lots of times where people put their mailing addresses as "foo at bar dot org" in a hopeful effort to keep spammers from scraping your mailing address. Heck, mail archive systems often have (and are deployed with) options to obfuscate email addresses systematically, using the same pattern: foo at bar dot com.

All it does is hurt usability.

Googlng for "* at * dot *" clearly shows lots of matches. It also matches all of the following variants, due to google searches ignoring brackets and such in words:

  • foo at bar dot com
  • foo [at] bar [dot] com
  • foo (at) bar (dot) com
  • ... etc ...
Query, scrape, replace 'at' and 'dot' as desired. I now have 54 million email addresses. What now?

Seems like this effort only serves to have people fool themselves as well as to impede usability. It certainly won't protect you from spam. Why is this method used?

procmail, formail, and duplicates

People are fundamentally bad at using 'reply-all' - or perhaps it is that 'reply-all' itself is bad. Either way, reply-all to lists will reply to the list AND to the poster, who most likely is a member of the list anyway. So, s/he gets two copies. This irritates me because I have to end up removing duplicates myself, manually.

Worry not, here comes procmail and formail to save the day. The following 2 rules will put duplicates in a 'duplicates' folder.

# Keep track of message IDs.
| formail -D 8192 messageid.cache

# I don't want to see duplicate messages
A special note on duplicate detection. Every email (hopefully) will have a Message-ID. Replies will hopefully have an In-Reply-To or a References header that specified the Message-ID that it is in response to. This is how MUA's (mail user agents) know how to sort mail by "thread."

At any rate, formail -D tells formail to look in the cache (messageid.cache) for an existing message id. If it's not found, it is stored and formail exits with failure status. If it is found, formail exits with a success

Read the procmailrc manpage if you want to know what the W, h, c, or a flags mean on rules.

nmh mail archiver

I went over quota. My mail backlog was 132 megs so it was time to archive mail.

This was built specifically for my needs but it'll work for any mh mailbox pending you know what to do...

mailarch script

Partial output from my run... (I only started using NMH in July)

fury(~) [34] > ./bin/mailarch
.archive+ has 3057 messages  (1-3469); cur=143; (others).
Jan.2003.tar:  scanning... no email this month.
Feb.2003.tar:  scanning... no email this month.
Mar.2003.tar:  scanning... no email this month.
Apr.2003.tar:  scanning... no email this month.
May.2003.tar:  scanning... no email this month.
Jun.2003.tar:  scanning... no email this month.
Jul.2003.tar:  scanning... tarring... bzipping... -  69 mail
Aug.2003.tar:  scanning... tarring... bzipping... -  140 mail
Sep.2003.tar:  scanning... tarring... bzipping... -  27 mail
Oct.2003.tar:  scanning... tarring... bzipping... -  246 mail
Nov.2003.tar:  scanning... tarring... bzipping... -  25 mail
Dec.2003.tar:  scanning... tarring... bzipping... -  189 mail
Jan.2004.tar:  scanning... tarring... bzipping... -  617 mail
Feb.2004.tar:  scanning... tarring... bzipping... -  811 mail
Mar.2004.tar:  scanning... tarring... bzipping... -  932 mail
Apr.2004.tar:  scanning... no email this month.
May.2004.tar:  scanning... no email this month.
Jun.2004.tar:  scanning... no email this month.
Jul.2004.tar:  scanning... no email this month.
Aug.2004.tar:  scanning... no email this month.
Sep.2004.tar:  scanning... no email this month.
Oct.2004.tar:  scanning... no email this month.
Nov.2004.tar:  scanning... no email this month.
Dec.2004.tar:  scanning... no email this month.

yes, even more ksh prompt fun...

So the next thing that bothered me about my prompt was the fact that sometimes I'd have some crazy long directory filling up 90% of the line - this was a bad thing. So I set out along with my companion, sed, and together we squashed this beast.

PS1='$(A=$?; [ $A -ne 0 ] && A="!!{$A}!! " || A=""; SPWD=$(/bin/pwd | /usr/bin/sed -Ee "s,(/usr)?$HOME,~,; sz(/[^/]+/).*(/.{20,})$z\1...\2z"); /bin/echo -n $HOST"("$SPWD") [!] ${A}${Z} " )'

[ -w "/" ] && Z="#" || Z=">"; export Z
PROMPT='$(A=$?; [ $A -ne 0 ] && A="!!{$A}!! " || A=""; SPWD=$(/bin/pwd | \
/usr/bin/sed -Ee "s,(/usr)?$HOME,~,; sz(/[^/]+/).*(/.{20,})\$z\1...\2z"); \
/bin/echo -n $HOST"("$SPWD") [!] ${A}${Z} " )'

case $TERM in
      PROMPT=${PROMPT%)*}'; /bin/echo -n "^[]2;"$HOST"("$SPWD") [!] ${A}^G" 1>&2)'
The part marked in bold is what actually shortens the path. This will take what was previously a terribly long prompt and shorten the directory... ie;
will become

Oh, and this new feature actually makes the overal content of $PS1 shorter by 3 characters! Instead of 257 characters, it's 254. This is due to a rewrite of part of the code - pwd and sed are only called one time now.

converting mbox to mh

I had a bit of mail in my old mbox files that I wanted to refile to mh, so here's the oneliner that does it.
cat main | \
perl -e '\
$x = 0; \
while (<>) { \
   if (m/^From /) { \
      $x++; \
      open(MAIL, "> $x"); \
   }; \
   print MAIL $_; \
main is the name of the mbox. After doing this, I simply used the refile(1) command to drop them in my main mh folder. <3 perl.

nmh mail reader, v1.1

mailfilter (my new mailreader for nmh) got a fairly important upgrade today. I added in both screen support and better pgp handling.
Screen is supported if you want to use it, see SCREEN_POLICY in the script.
Mail starting with -----BEGIN PGP SIGNED MESSAGE----- will now be sent through pgp_verify_command much in the same way that multipart/signed (pgp signature attachment) mail is.

So that was how I spent 4 hours this morning (among other projects...)

nmh mail viewer

"version 1" of my mail viewer for mh is done. It currently supports any number of viewers including w3m, links, lynx, less, more, vi, emacs, joe, and others. It also will do pgp verification on mail that is signed with a signature attached (Although mail that is simply armored and begin with -----BEGIN PGP SIGNED MESSAGE----- is NOT supported, yet).

Anyhoo, it supports multipart mail and will display HTML email properly (aswell as html attachments). If you want to try it, click the link on the right.

mh fun, still.

I'm still awake from last night, yadda yadda yadda.
So I got leet with my vim stuff and wrote a keymap that automatically generates an attached pgp signature. I should note, however, that you'll have to run mime from whatnow or run mhbuild yourself, before you send out your email.
" MH comp header/body separator
let g:mhseparator="---------"

if bufname(1) == '/u9/psionic/Mail/draft'
set tw=72
map \t :w<CR>1G:exec "/^" . g:mhseparator . "$"<CR>jyG:enew<CR>PGdd:w! ~/tmp/.draft<CR>:bn<CR>O#<text/plain<ESC>Go#<application/pgp-signature<ESC>:exec "r!gpg --detach-sign --no-secmem-warning --output - --armor --textmode ~/tmp/.draft"<CR>
This should be placed in your .vimrc. The only thing I'll really mention above is the g:mhseparator. This should be exactly the same line that separates your headers from your body (comp, repl, and forw formatting)
Just modify the variable in .vimrc to match your comp format.

One final note: To get the pgp signature mail part to play nice with mhbuild, you'll have to add this line to your .mh_profile

This just lets mhbuild know of the existance of Content-Type: application/pgp-signature.


So the other update is to my mailfilter script. It now supports better html stuffs and pgp signature verification. I've done a bit of testing with other people's pgp signature attachments (though not extensive) and trial runs verifying emails tagged by vim keymapping above. It seems to work pretty well.

more mh coolness

I got annoyed at html mail being displayed as.. well, plain text. So I stopped being a lazy fool and wrote a script to it right.

The product isn't quite finish at the time of posting, because I want to add lots of more features to it. This will run w3m on your mail if it matches one of the following conditions:
* The Content-Type of the mail is text/html
* The Content-Type is multipart/alternative and the first part is text/html
* The Content-Type is multipart/alternative and the second part is text/html (Useful when mail is transmitted in both text/plain and text/html