procmail
[Top] [All Lists]

whitelisting expected reply addresses

2004-02-21 18:22:50
I have had in the back of my mind for a while now the wish to permit
temporary whitelist caches, automatically, for people I originate mail
to and from whom I anticipate a reply.  I think I now have a working
model.  So I'll throw it out here to share and to see if there's useful
feedback.

I have whitelists that are updated whenever people write me and their
email gets past my spam and virus checks.  People not already in the
whitelists are automatically placed in a "new-candidate" holding area.
(Their email gets delivered immediately, assuming they got through my
spam checks; but they are not yet actually whitelisted.  The address
for possible [probable, if they've gotten this far] inclusion in my
whitelists is what is being held provisionally for my approval.)  I
run a shell script periodically when I am online, in order to view
new whitelist candidates and approve or disapprove them (with one
keystroke).  That part has all worked very well for many months.  (As
I explained a couple of months ago, I use a filename hash checked with
"test" rather than flat files that would be grepped.)  Still, new
correspondents are more likely than otherwise to end up in my spam
pile markes as false positives.  (Happens about 1% of the time for
me.)  I therefore have wished for a way to cache *expected* future reply
correspondents when I write them.  Now I have one.

The algorithm for this hit me after David Tamkin's very clever recent
use of formail with only one pass to apply the utility's -D option in an
expanded manner.

First of all, I wanted a way to place addresses in the cache.  I already
have had in place a very rigorous check for people sending from my local
system, that bypasses my spam checks.  It would be difficult to spoof my
"$LOCALSOURCE" characterization, and so far it has never happened.  So
that's safe to start with, since I'm only going to allow in, to add an
address to the cache, things that I send through my usual mail server.

I write the new party, as usual.  I place in the Bcc: line, though, a
looping address that I will not divulge.  It gets returned to me with a
keyword present, and that triggers the cacheing:


 :0
  * $ LOCALSOURCE  ??  $TRUE
  {
     :0  # 040222 () create a cache for expected correspondents
      *  KEYCHECK ?? ^^munged^^
      | formail -I "From" -I "Return-Path:" -R "To:" "From:" -rD 1024 To.Cache

     SWITCHRC = $SPOOL
  }

The formail part is all new.  ($LOCALSOURCE Mail not containing
the right $KEYCHECK is just ordinary stuff frm my local system,
and gets shunted to the $SPOOL rc for immediate delivery.)
The formail action eats this mail; the message's only purpose
was to create the cache, since it is an extra copy I am looping
back to myself when I sent the email out.

Okay, I should also mention that this goes below my existing
whitelist check, which would already have sent to my mailspool
properly whitelisted correspondents' messages.

Fine; now I have the address cached.  Now the email from the party
comes in.  Here is what finds it:

 :0 W  # 040222 () check cache of expected correspondents
  * ? fgrep -wis -e "$RP" To.Cache
  { SWITCHRC = $SPOOL }

I need to add that $RP has been assigned earlier in my rc,
and represents the Return-Path address stripped of surrounding <>'s.

Seems to work fine.  But I'll test it more in coming days.

-- 
dman

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail