procmail
[Top] [All Lists]

Re: Procmail question (Please email me direct)

1997-10-15 18:02:46
At 06:25 PM 10/15/97 -0500, Fireball wrote:

I've been struggling to write a procmail filter to work with spam mail.   
Here's the rules that I'd like to have in it:

1) If it's got my email address in the To: field, write it to my mailfile.

# Use ^TOmy(_at_)address for *ANY* address (to/cc/other)
# Use ^To:(_dot_)my(_at_)address for JUST the To: field

:0:
* ^TOmy(_at_)address
| mailfile

2) If it's got an address in my '.allowlist' file, then write it to my    
mailfile.

# I'll assume such an address could be in any header (except for subject,
# which I usually choose to exclude).  If you want to specify certain
# fields (to/from/return-path/etc), use -xFieldname: instead of -ISubject:
# below).  You might want to add -IReceived: as well, so that your address
# showing up as a "for ... " won't trigger is as an okay message).
#  $FORMAIL should be defined to be the path to the formail executable, and
#  $EGREP should be the path to the egrep executable (I use a GNU one).
# The data file contains addresses or whatever, on separate lines.
# I'm big on using fully qualified paths for my utilities, rather than
# expecting them to be in whatever my path definition is - it is a hair
# faster, plus the process of determining the path to the executable (when I
# write the script) tells me that the utility is in fact present on the
# system).  I define the app paths in the .procmailrc, but include actual
# recipes using INCLUDERC.

HPHRASE=path/hphrase.dat # header phrase database

:0:
* $? $FORMAIL -ISubject: | $EGREP -i -f $HPHRASE
| mailfile

3) If it's got any other address, write it to my '.spam' file.

# After the above two, if the message is still there:

:0:
| .spam


That should do the trick.  Alternatley:

HPHRASE=path/hphrase.dat # header phrase database

:0:
* !^TO: my(_at_)address
* !$? $FORMAIL -ISubject: | $EGREP -i -f $HPHRASE
| .spam

# Disable the following if you just want the "okay" messages left in your
# *mailspool* (versus a mail file):

:0:
| mailfile


If anyone spots an error in this, please let me (as well as the
non-subscriber Bryan) know.  I just jotted these up - I don't employ this
approach, so none of it is debugged.

I am not on this list, so please email me directly!

I've carboned you on the reply to the list then.  Perhaps you might
consider subscribing to the list, at least in digest form?  It is an
excellent resource.

---
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.

 Sean B. Straw / Professional Software Engineering
 Post Box 2395 / San Rafael, CA  94912-2395

<Prev in Thread] Current Thread [Next in Thread>