##### addrlistlookup.rc # # Resource file for procmail. # Looks up whether an email address in the current msg is found in a list. # The email headers which are searched are currently: # From:, Reply-To:, "From ", Return-Path: # The address list is in a file which can have comments, and is translated into # a procmail-readable file. This happens automatically the first time it is # used after each change. # The addresses in the list are case-insensitive, and use extended regular # expressions. They are anchored on both sides to something appropriate for an # email address. # # Uses GNU /usr/bin/test, and egrep. Contains shell code. # I don't really like the whole concept very much yet, so it's likely to change. # It doesn't allow to specify which mail headers to examine - would that be # useful? # # Variables, in (set before calling): # ADDRESSLIST The file with the list of email addresses to look up in. # A copy without comments is created as $ADDRESSLIST.pm, # so procmail needs write access to the directory it's in. # Variables, returned: # INLIST Set to "1" if email is from this list, unset otherwise. # # Run with e.g.: # ADDRESSLIST="filewithlistofaddresses" # INCLUDERC=yourpath/addrlistlookup.rc # :0 # * INLIST ?? ^^1^^ # { ... } # in your $HOME/.procmailrc. # # The latest version is always available from: # http://volker.dnsalias.net/soft/procmail/ # # Copyright (C) by Volker Kuhlmann # Released under the terms of the GNU General Public License (GPL) Version 2. # See http://www.gnu.org/ for details. # # Volker Kuhlmann # 22 Sep; 30 Oct; 6 Nov 2002 # 16 May 2003 # 5 Jan; 3 Mar 2004 # 24 May 2005 # ## Init INLIST= ## Address list lookup # (Recipe is executed if exit code is 0) # (Solaris 2.7 grep does not have "-f patternfile", using egrep -f) # (Solaris 2.7 egrep -f gives syntax error for empty line in pattern file) # (Solaris 2.7 fgrep -i -f: the -i doesn't always work, using egrep) # (Conclusion: Solaris 2.7 = POS) # First check if the address list file has been modified, and if yes rewrite # the stripped copy of it. # Headers to examine: add Sender: ? :0 * $ ! ADDRESSLIST ?? ^^^^ * $ ? test -f "$ADDRESSLIST" * $ ? ( \ /usr/bin/test "$ADDRESSLIST" -nt "$ADDRESSLIST".pm \ -o ! -e "$ADDRESSLIST".pm \ && sed '/^$/d; /^[#%!]/d; s/.*/(^|[^a-z0-9_.-])&($|[^a-z0-9_.-])/;' \ <"$ADDRESSLIST" >"$ADDRESSLIST".pm; \ formail -zxFrom: -zxReply-To: -zx"From " -zxReturn-Path: \ | egrep -i -f "$ADDRESSLIST".pm \ ) { INLIST=1 } # Damn, this effectively creates a substring search, unless all email addresses # in the input are already anchored # && egrep -v '^[ ]*($|[#%!])' \ # "$ADDRESSLIST" >"$ADDRESSLIST".pm; \ # && sed '/^$/d; /^[#%!]/d; s/.*/(^|[^a-z])&($|[^a-z])/;' \ # <"$ADDRESSLIST" >"$ADDRESSLIST".pm; \ ##### EOF addrlistlookup.rc