Re: Procmail for dummies

Date: Wed 18 Sep 2002 - 15:48:20 GMT

  • Next message: Smart, Dan: "RE: Procmail for dummies"

    Procmail has a very steep learning curve, but is power is quite
    If you want to redirect mail to specific users on that system, then you
    could end a recipe with the line "!"
    That isn't flaky at all. Its a bit more trouble to do this from a
    systemwide procmailrc.
    I would suggest starting by reading "man procmailrc", for some information
    on the configuration file, and "man procmailex" for some configuration
    I think you would want to use the "To" function in a recipe's search, to
    select a specific recipient domain, for a specific filter.
    Have you read the postfix.txt file in the contrib directory of the Anomy
    distribution. I am not familiar with postfix, and I just took a look at
    this file, but I'm using it for a common reference point to give you some

    In section 4, the file refers to the file /etc/procmailrc, with entries

    :0 c

    :0 fw
       |/usr/local/anomy/bin/ /etc/sanitizer.cfg

    The first line, just copies all of the mail to an mbox style file named
    The ":0" begins the recipe, and the "c" says to copy the data, and not to
    drop anything.
    The "ANOMY=/usr/local/anomy/" just sets an environment variable which
    tells the sanitizer where it lives (that need to be where you put it, but
    /usr/local/anomy is a good location).
    The ":0 fw" is a new recipe which filters the mail, and waits for the
    The mail is then filtered as input to the program
    "/usr/local/anomy/bin/" with the command line option selecting
    "/etc/sanitizer.cfg" as its configuration.

    Replacing this recipe with the following two recipes:

    :0 fw
    * ^To:.*example1\.com
       |/usr/local/anomy/bin/ /etc/sanitizer.cfg1

    :0 fw
    * ^To:.*example2\.com
       |/usr/local/anomy/bin/ /etc/sanitizer.cfg2

    Would take mail directed to a specific, and sanitize it
    with the sanitizer.cfg1 ruleset, and would filter mail to a using the sanitizer.cfg2 ruleset.

    I only mentioned it to point out how very easy it is to goof up in a
    regular expression.
    This will ONLY filter mail sent "To" a user. CC, and BCC, etc will not be
    filtered. :(
    Fortunately, procmail has set up some neat predefined regular expressions
    to help with this.
    Replacing the "^To:" with "^TO_" or "^TO" will substitute in a rather
    large regular expression to help this out. I leave it up to you to figure
    out the difference between the two (hint: its in the procmailrc man page)

    Does this help any?

     /\ \
    | |\ Robert C. Litman \
    | | | |
    \/__| |
        | |
      __| |
     /\ | Desk: (631) 501-2572 |
    | | | Fax: (631) 514-6626 |
    | |/ /

    "Wil McGilvery" <>
    09/18/2002 10:53 AM

            To: <>
            Subject: [anomy-list]: Procmail for dummies

    I am currently running a Postfix Server that acts as a gateway and as a
    local mail host for several domains. I have been experimenting with Anomy
    and SpamAssassin and I wish to be able to set different filter settings
    for each domain. I also do not wish to filter outgoing mail. (I currently
    use a script (not procmail) that filters all mail that arrive at the

    I have been reading up on Procmail and it appears that it can only be used
    to direct mail locally. I found a "To" function that that could be used to
    redirect mail, but I also read that this set up is flaky at best.

    What have other people done? Where can I find a "How To" For the procmail


    Wil McGilvery
    Manager, Digital Media

    Lynch Technologies Inc.
    416-744-0406 FAX


    hosted by