Subject: sending-filter to inhibit munged addresses?

From: Hugh Sasse Staff Elec Eng <[email-masked]>
Date: Tue, 11 Nov 2003 10:12:21 +0000 (GMT)

Scouring the web I see there are sending-filters for pine, with
parameters which map to the temp files pine uses when creating
messages.  The docs are OK, but I was wondering if there are any
examples out there of such filters so I can get a better feel for
this.

These days there seems to be an increasing tendency for people to
munge addresses in an attempt to foil spammers.  The RFCs say this
should not happen, but they pre-date the present scale of the spam
problem.  What I want to do is to prevent myself from mailing to
addresses that contain /spam/i -- things like
[email-masked], by mistake.  I don't need the filter to
correct the address, just prevent me sending when I've forgotten to
check whether the address is munged.  Clearly I need to be able to
override the block if I want to sent to anti-spam sites which
legitimately have spam in the domain name.

This needs access to the To:, CC: and BCC: headers, and I'll have to
interact with it to some extent.  If this is possible and anyone has
examples of filters that access this info then I'd be interested in
seeing them so I can be more confident about crafting something
myself.

        Thank you
        Hugh
-- 
-----------------------------------------------------------------
 For information about this mailing list, and its archives, see: 
 http://www.washington.edu/pine/pine-info/
-----------------------------------------------------------------

---

From: Kenneth Crudup <[email-masked]>
Date: Tue, 11 Nov 2003 11:13:39 -0800 (PST)

On Tue, 11 Nov 2003, Hugh Sasse Staff Elec Eng wrote:

> problem.

Hrmph. If anyone *sends* me (non-spam, solicited) mail where I have to
unmunge their address to reply to 'em, they'll be waiting for hell to
freeze over before I bother to reply. While I can understand (if not
condone- that's what "procmail" is for) address munging in public fora,
having it go out that way on private E-mail is just *dumb*.

	-Kenny

-- 
Kenneth R. Crudup  Sr. SW Engineer, Scott County Consulting, Los Angeles
H: 3801 E. Pacific Coast Hw #9, Long Beach, CA 90804-2014 (888) 454-8181
W: 26601 Agoura Road, Calabasas CA 91302-1959             (818) 444-3685

---

From: Hugh Sasse Staff Elec Eng <[email-masked]>
Date: Wed, 12 Nov 2003 19:37:42 +0000 (GMT)

Thanks to an example from Eduardo Chappa I now have a working
script.

The script below is written in ruby.  If you are unfamiliar with
Ruby see for example http://www.ruby-lang.org/ and
http://www.rubygarden.org/

The filter is setup using the M(enu) S(etup) C(onfig) screen in
Pine.  The commandline supplied to sending-filters is described in
the comments at the script start.

Additional remarks:
When the script "fails" -- i.e. traps a munged address, the screen
clears and there is a failure message from Pine, then one is told to
hit return, before the status line (supplied in _RESULTFILE_) is
displayed.  There seems to be no way to inhibit this sequence of
events, and instead just have the message unsent with the supplied
status line displayed.  (This latter behaviour is what happens when
no recipients are specified, for example.)

The sending-filter can fail either by deleting the _TMPFILE_ or by
returning a non-zero exit status. (Actually, I have not tested what
positive values of exit status achieve, only 0 or negative.) Both of
these modes cause the screen to clear as above.

I hope this information is of use to someone else.
        Thank you,
        Hugh

#!/usr/local/bin/ruby -w

# Pine filter.  When setup with
#
# sending-filters=/full/path/to/this/filter _TMPFILE_ _RESULTFILE_ _RECIPIENTS_
#
# then ARGV[0] contains the name of the temp file holding  message
# as it is, and as it will be when filtered.  To cause this to fail
# delete this file. Deleting the file still leaves the message body
# in pine as it was. Alternatively exit with -1 instead of 0.
#
# ARGV[1] is the results file that will be created
# by this program, i.e. a status message.
#
# ARGV[2..-1] will be the recipients, including those in bcc lines
#

message = nil
ARGV[2..-1].each {|recipient|
    case recipient
    when /spam/i, /example.com$/i
        message = "#{recipient} possibly munged"
        break
    end
}

unless message.nil?
    open(ARGV[1],"w"){|fp| fp.puts message }
    File.delete(ARGV[0])
    exit(-1)
end
exit(0)