procmail
[Top] [All Lists]

Re: problem with rule and logging question

1999-01-01 11:09:04
Jerry Preeper asked,

| I have the following rule in one of my rc. files and it doesn't seem to be
| catching the junk mail
| 
| :0B:
| * ^^(This is a one-time only email)
| ! spam(_at_)domain(_dot_)com

| I have sent an email with the item in parentheses above to a test address
| and the mail still comes to the address I'm testing and not getting
| forwarded.  Anyone have any ideas what I'm missing.

Parentheses are special grouping characters.  To match a literal parenthesis,
you have to escape it with a backslash (or put it inside square brackets):

  * ^^\(This is a one-time only email\)

Also, there is no need or reason for a local lockfile (the second colon on
the flag line) on a recipe whose action is to remail the message to another
address.  If the recipe matched and you didn't take off the second colon,
procmail would complain about insufficient information to infer the name for
the local lockfile.

| I also have a question about logging the rc file or even the rule that
| denied the mail.  I have set up my .procmailrc file with a bunch of these
| lines to separate file making it easier for me to add things.
| INCLUDERC=$PMDIR/rc.banneddomains
| I would like to be able to track which rule denied the email so I can track
| this info and was wondering how I might go about this.  Anyone have any
| ideas if this is possible and how to do this.

Yes, it is possible, but exactly how depends on the other recipes into which
you want to integrate it.  If each of your INCLUDERCs has recipes that dump
to /dev/null, for example, you can change them from

  :0 flags
  * conditions
  /dev/null

to something like

  :0 flags
  * conditions
  {
   # When no shell metacharacters are present, procmail will replace
   # $_ with the name of the current rcfile or INCLUDERC.

   LOG="trashed in $_
"  # Note the closing quotation mark on the next line.

   :0
   /dev/null
  }

If the action is to dump the message unseen and there are no more rcfiles
named on procmail's command line, then here's a shortcut:

  :0
  * flags
  { LASTFOLDER="trashed for [insert reason here]"  HOST }