procmail
[Top] [All Lists]

Re: Messing with E-mail Headers

1996-08-13 14:28:51
    > > :0
    > > * ^To: [0-9]
    > > {
    > >     :0
    > > |/usr/local/bin/junclient
    > > }

    > > Since the "^To: [0-9]" condition failed, then its recipe action
    > > is not performed.  The next recipe is then examined.  If there
    > > are no more recipes, then procmail tries to deliver the e-mail
    > > to the default mailbox for the current user.  If there is no
    > > current mailbox for the current user (an e-mail list), then
    > > procmail *bounces* the e-mail.
    > 
    > That is what I thought procmail was supposed to do, but I couldn't
    > seem to get it to work (that is it would not write to an existing
    > user's mailbox). The problem, I discovered, actually had nothing
    > to do with procmail, it had to do with my FX/etc/passwd %[^:] line
    > in my sendmail.cf and the rule that I had added to deal with $~X
    > users - the problem was that the currently installed sendmail had
    > not compiled in the SCANF option when it was created. :(

It sounds like your rule is not setting the userid before having
procmail invoked.

    > > By the way, the recipe condition, as it stands, is not very
    > > flexible.  What about the case where there is more (or less)
    > > than exactly one space between the color and the first number?
    > > Ie:
    > > 
    > >     To:      1234(_at_)foo(_dot_)bar(_dot_)com
    > >     Subject: Problems
    > > 
    > 
    > Is there a way to make the recipie handle such an issue? I cannot
    > see any way to make it so that it would handle an arbitrary number
    > of spaces...  do you?

You should read up on regexps.  Especially with the extended regexps
used in procmail, it is very easy match variable length patterns.  To
take care of the case above, use a recipe like:

    PATH=$PATH:/usr/local/bin

    :0
    * ^To:[     ]*[0-9]
    | junclient

The '[  ]*' means an arbitrary number of spaces or tabs (including none).

If you wanted to allow for arbitrary comment text in front of the
address, such as this example:

    To: "The Defender Of the Truth" 12345(_dot_)4567(_at_)aohell(_dot_)com

then you might consider a recipe condition like this:

    * ^To:(.*[^0-9a-zA-Z])?\/[0-9.]+

after a successful match, $MATCH will be the user-portion of the address
(assuming that the user addresses are all numeric or periods, like
A-O-HELL accounts).

*Please* read up on regexps: see the man page on egrep(1).

G'luck
_____________________________________________________________________
Alan Stebbens <stebbens(_at_)sgi(_dot_)com>      http://reality.sgi.com/stebbens

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