[hashcash] Re: Using hashcash with Mutt and Vim

  • From: "Todd A. Jacobs" <nospam@xxxxxxxxxxxxx>
  • To: hashcash@xxxxxxxxxxxxx
  • Date: Mon, 21 Mar 2011 20:30:14 -0700

On Mon, Mar 21, 2011 at 2:38 PM, Aaron Toponce <aaron.toponce@xxxxxxxxx> wrote:
> Of course, this is just for minting tokens. I still need a method for
> verifying tokens with Mutt. Help with that will be appreciated too.

I no longer use Mutt, but my solution used to involve tmda-sendmail
for including the hashcash tokens on outbound email, and procmail for
validating inbound hashcash tokens. This was my procmail recipe for
validating hashcash tokens "way back when." I'm pasting it here for
you, but if the formatting doesn't survive transmission, you can
download the source file directly at:

    http://codegnome.com/scripting/showscript.php?script=hashcash.proc

Alternatively, you can follow the directions here:

    http://tmda.sourceforge.net/cgi-bin/moin.cgi/TmdaHashCashHowto

for a simpler TMDA-based solution if you don't need to include the
results of your check in the email headers. Hope this helps.

######################################################################
# Hashcash Procmail Recipe
######################################################################
# Author:
#       Todd A. Jacobs <bash_junkie@xxxxxxxxxxxxx>
# Revision:
#       $Revision: 1.5 $
# Purpose:
#       Process hashcash-stamped emails. Don't just validate it; include
#       the results in the email headers. This is partly for debugging,
#       but it also provides more tokens for Bayesian filters such as
#       bogofilter to use in differentiating spam vs. ham.
# Dependencies:
#       This recipe obviously depends on the hashcash binary being
#       somewhere in the PATH.
# Caveats:
#       None currently known.
######################################################################
:0
* $^X-Hashcash: .*\/[^:]+@${MYDOMAIN}
{
    # Hashcash sends its output to stderr, so we capture it and then
    # ensure that every line but the first is indented in order to
    # comply with RFC 822.
    RESULT=`hashcash -cvMXdp 1d -b20 -f $HOME/hashcash.db -r $MATCH 2>&1 | \
            sed -e '1!s/^/\t\t   /'`

    # Filter successful mail through formail, and append the results.
    :0Afw
    | formail -i "X-Hashcash-Validated: yes" \
      -i "X-Hashcash-Result: $RESULT"

    # If the hashcash stamp is invalid, append the results and let further
    # filtering take place.
    :0Efw
    | formail -i "X-Hashcash-Validated: no" \
      -i "X-Hashcash-Result: $RESULT"

    # Deliver the mail, bypassing further filtering. Disable this if you
    # still want to do further processing (e.g. Bayesian filtering)
    # before delivery.
    :0:
    $DEFAULT
}

Other related posts: