procmail
[Top] [All Lists]

Re: selective sender

1998-09-02 10:40:09
|Wed 1998-09-02 Alexandre Farcy 
<Alexandre(_dot_)Farcy(_at_)prism(_dot_)uvsq(_dot_)fr> list.procmail
| 
| i'm trying to pipe the mail i receive to a perl script only if the
| sender corresponds to an email address in a special file that contains
| one email per line...


I'd do it with my modules, because getting the email exploded is
easiest that way. (See X-info header where to get pm-code.shar)
Substitute Sender with From if that si closer what you wanted.


    RC_ADDRES  = $PMSRC/pm-jaaddr.rc
    DB_ADDRESS = $HOME/.procmail/email.db

    :0
    * ^Sender:\/.*
    {
        INPUT     = $MATCH      # INPUT is argument to RC_ADDRESS subroutine
        INCLUDERC = $RC_ADDRESS
    }

    :0
    * ! ADDRESS ?? ^^^^
    * $GREP "$ADDRESS" $DB_ADDRESS
    {
        ..ok found, what next?
    }

I incluude manpage exerpt below to undertand the recipe.
jari

Pm-jaaddr.rc -- extract 'foo(_at_)some(_dot_)com' email address from variable 
INPUT
 
    Example input
 
            "From: foo+procmail(_at_)this(_dot_)site(_dot_)com (Mr. foo)"       
 traditional
            "From: foo-procmail(_at_)this(_dot_)site(_dot_)com (Mr. foo)"       
 new styled
 
        NOTE: M$SOFT mailers tend to send idiotic smart quotes "'Mr. foo'"
        and this recipe ignores these two quotes ["'] as if message had
        only the standard ["]
 
    Returned values
 
            ADDRESS     "foo+procmail(_at_)this(_dot_)site(_dot_)com"
                        containing the email address without <>
 
            ACCOUNT     "foo+procmail"
                        all characters before @
 
            ACCOUNT1    "foo"
                        characters before plus: account1+account2(_at_)site
                        Note, if there is no "+", this is same as ACCOUNT.
 
            ACCOUNT2    "procmail"
                        _only_ set if plus found: account1+account2(_at_)site
 
            SITE        "this.site.com"
                        all characters after @
 
            DOMAIN      "site.com"
                        the main domain, preceding words in site are
                        considered subdomain (local) addresses.
 
                            sub.sub.domain.net
 
                        "com"
            NET         last characters after last period ( net,com,edu ...)
 
            COMMENT     Anything unside parenthesis (Mr. Foo) or if no
                        parentheses found, then anything between quotes
                        "Mr. Foo"
 
            COMMENT_PLUS Anything after the "+" in the comment, like
                         "Mr Foo+mail.usenet" --> "mail.usenet"
 
        Additionally there is variables DOT1 DOT2, which behave like
        ACCOUNT1 and ACCOUNT2, but in respect to dotted firstname.surname
        type address:
 
                john(_dot_)doe(_at_)site(_dot_)com
 
                ACCOUNT1    = john.doe
                ACCOUNT2    = <empty>
                DOT1        = john
                DOT2        = doe
 
        If there is plus, the ACCOUNT2 is defined
 
                john(_dot_)doe+foo(_at_)site(_dot_)com
 
                ACCOUNT1    = john.doe
                ACCOUNT2    = foo
                DOT1        = john          (in respect to ACCOUNT1)
                DOT2        = doe           (in respect to ACCOUNT1)
 
 
        Variable ERROR is set to "yes" if INPUT wasn't recognized or parsing
        the address failed.
<Prev in Thread] Current Thread [Next in Thread>