procmail
[Top] [All Lists]

Re: Simple Q. (fwd)

1996-07-17 22:42:18
:0
* ^From(_dot_)*mailer-daemon(_at_)(_dot_)*umich(_dot_)edu
$TRASH
:0
* ^From(_dot_)*reply(_at_)remail(_dot_)ecafe(_dot_)org
$TRASH

Try:

:0:
* 
^From.*(mailer-daemon(_at_)(_dot_)*umich\(_dot_)org|reply(_at_)remail\(_dot_)ecafe\(_dot_)org)
$TRASH

Some points to note:
- This rapidly gets out of hand if you have several addresses to match
- Are you aware of the ^FROM_DAEMON token?
-----------

I am still looking for a better way of doing this, as Tim said, this will
get out of hand, I will probably end up with a large number of addresses 
in this list.  I would like to be able to just add the address in a one 
per line list yet still be able to have pattern matching.

What is the ^FROM_DAEMON token?

FROM_DAEMON is described in procmailrc(1), near the end, in the
MISCELLANEOUS section.

As for a "better" way, it all depends upon your own sense of aesthetics.

First, did you know that you can continue regexps and indent the continuations? 

    :0:
    * ^From.*(mailer-daemon(_at_)(_dot_)*umich\(_dot_)orig|\
              reply(_at_)remail\(_dot_)ecafe\(_dot_)org|\
              hose(_dot_)head(_at_)somewhere\(_dot_)com|\
              president(_at_)whitehouse\(_dot_)gov|\
              vice-president(_at_)whitehouse\(_dot_)gov|\
              newt(_at_)congress\(_dot_)gov|\
              news@|\
              nobody@|\
              spam-king@|\
              root)
    $TRASH

This is both readable and concise.

If you are worrried about how long the regexp can be, set LINEBUF to a
sufficiently large number.

    LINEBUF=2048

Secondly, if you ever wish to perform the same operation on several
combinations of patterns, such as ADDRESS and DESTINATION pairs, then
create a "subroutine" recipe file in which the operation is performed,
and then repeatedly invoke the recipe file using INCLUDERC=subfile.rc.

This is an example of how I do my "prefiling":

  ADDR=scout-report             DEST=info/scout-report/. INCLUDERC=mh-check.rc
  ADDR=procmail                 DEST=info/procmail/.    INCLUDERC=mh-check.rc
  ADDR=perl-users               DEST=info/perl/.        INCLUDERC=mh-check.rc

  INCLUDERC=mh-save.rc

Here are mh-check.rc and mh-save.rc:

# mh-check.rc
#
# Procmail recipe file to check an address ADDR for MH filing.
# If the address matches, append DEST to MH_DEST.
#
# After all checks are complete, invoke mh-save.rc to save the
# message into the appropriate folders.
#
# Set these variables before invoking:
#
# ADDR  Address to which addressed mail will be filed
#       into the named folder.
#
# DEST  Destination into which addressed mail will be 
#       dropped.
#
# INCLUDERC=mh-check.rc

:0
* ADDR ?? .
* DEST ?? .
* $ ^TO$ADDR
{ MH_DEST="$MH_DEST $DEST" }


# mh-save.rc
#
# Procmail recipe file to save the current message to 
# a list of one or more folders set by mh-check.rc.
#
# Set the variable MH_DEST before invoking.
#
# INCLUDERC=mh-save.rc
#
# If the message is filed into an MH folder, LOGABSTRACT is
# set to "off" so a duplicate log is not created.

:0
* MH_DEST ?? .
{
  :0 fh
  | formail -A "X-Filed: $MH_DEST"

  :0 c:
  $MH_DEST

  LOGABSTRACT=off
}

Hope this helps.

___________________________________________________________
Alan Stebbens       <stebbens(_at_)sgi(_dot_)com>       (415) 933-6437
Silicon Interactive Group,   Silicon Graphics, Inc.   (SGI)
M/S:9L991, 2011 N. Shoreline Blvd., Mountain View, CA 94043

<Prev in Thread] Current Thread [Next in Thread>
  • Re: Simple Q. (fwd), Alan Stebbens <stebbens(_at_)anywhere(_dot_)engr(_dot_)sgi(_dot_)com> <=