procmail
[Top] [All Lists]

Re: Please help with $MATCH

1997-01-10 20:44:39
    > The bounced message subject procmail sees looks like this:
    > 
    > Subject: BOUNCE: Non-member submission from 
[user(_at_)roxy(_dot_)sfo(_dot_)com]
    > 
    > So I (try) to extract the email address from this by:
    > 
    > :0c
    > * $ ^From $SERVER
    > * $ !^X-Loop: $LOOP_TEXT
    > * $ ^Subject: BOUNCE $LIST_NAME: Non-member submission from \[\/.*\]
    > {
    >    SENDER="$MATCH"
    > 
    >    (-- rest of recipe sends a message to $SENDER --)
    > 
    > 
    > Now, this works *most* of the time, but once in a while the message to
    > $SENDER bounces back because it picks up the "]" at the end of the email
    > address in the subject line above:

The MATCH is set to all characters which are *matched* after the "fence"
operator: \/.  So, use a more discriminating regexp; like one of these 
(take your pick):

  * $ ^Subject: BOUNCE $LIST_NAME: Non-member submission from \[\/[^]]+

or

  * $ ^Subject: BOUNCE $LIST_NAME: Non-member submission from 
\[\/[a-zA-Z0-9(_at_)_(_dot_)-]+

    > Here is another bounced message that worked fine - I'd guess because of 
the
    > difference in the email address (">"), but I don't understand why.
    > 
    > Subject: BOUNCE: Non-member submission from [Ed User 
<eduser(_at_)scs(_dot_)unr(_dot_)edu>]

This works because when angle-brackets are present, most Sendmail
rewrite rules and mail user agent header parsers ignore the text
outside of the angle brackets.  

When angle-brackets are not present, then it is more difficult for
address parsers to decide what characters are part of the address and
what are not.

Don't forget that the parsers have to handle the very strange email
addresses such as seen on X-400, UUCP, DECNET, and other mail systems.

So, the bottom line: make your regexp more precise.

G'luck.

___________________________________________________________
Alan Stebbens <aks(_at_)sgi(_dot_)com>      http://reality.sgi.com/aks

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