procmail
[Top] [All Lists]

RE: extracting the TO username

2000-05-18 07:32:08

Thanks to all the suggestions ... they have been very helpuful.

After trying out the several suggestions, I've decided to run with David's
suggestion:

  :0i
  * ^TO_\/.*
  * ^Subject:.*test
  USERNAME=| myscript "$MATCH"
   :0a
   ! $USERNAME

Since * ^TO_\/.* only gives the full addresse info and not just the username
I'm interested in, I modified myscript to extract the username before
processing it. I had originally tried dman's suggestion:
* ^To:.*\/[^< @ ]+
but that did not work with the format
To: "User Name" <user(_at_)domain(_dot_)com>

Thanks for all your help!
_Rav.

-----Original Message-----
From: David W. Tamkin [mailto:dattier(_at_)ripco(_dot_)com]
Sent: Tuesday, May 16, 2000 4:07 PM
Cc: Rav Ahuja; procmail(_at_)informatik(_dot_)rwth-aachen(_dot_)de
Subject: Re: extracting the TO username


Lee suggested to Rav,

| :0

An 'i' flag  would be a good idea there, since mysccript is not going to
read
the message as stdin.

| * ^TO_\/*

Has to be .*; don't confuse shell globbing patterns with regexp syntax (yes,
the sublte differences do take some time to get used to).

| USERNAME=`myscript "$MATCH"`

That should be

  USERNAME=| myscript "$MATCH"

| {

You can't have a left brace hanging loose like that.  It has to be the
action line of a recipe.

|  :0
|  * ^Subject:.*test
|  ! $USERNAME
| }

So legit syntaxes would be

  :0i
  * ^TO_\/.*
  * ^Subject:.*test
  USERNAME=| myscript "$MATCH"
   :0a
   ! $USERNAME

or

  :0
  * ^TO_\/.*
  * ^Subject:.*test
  {
   USERNAME=`myscript "$MATCH"`

   :0
   ! $USERNAME
  }

Just from looking at it, I would not be too confident about this:

  :0
  * ^Subject:.*test
  * ^TO_\/.*
  ! `myscript "$MATCH"`

because then myscript and the MTA would be fighting over trying to get the
message text as stdin, and I'm not sure what the results would be.

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