procmail
[Top] [All Lists]

Re: Getting receptor with formail

1997-04-18 09:16:00
Gerardo Esteban Malazdrewicz <gerardo(_at_)unq(_dot_)edu(_dot_)ar> writes:
      Here we have an account which receives mail from various aliases.
Then, I must modify the subject so the new one read: [$BANNER] $SUBJECT.
But $BANNER = echo $RECEPTOR | cut -d"@" -f1 | cut "<" -d2

If I use " $RECEPTOR=`formail -zx "To:"` " $RECEPTOR is OK 
If I use " $RECEPTOR=`formail -zx "To:" | cut -d"@" -f1 | cut"<" -d2` "
then $RECEPTOR is EMPTY :(

You've told us what you've tried, but you haven't told us what you want.
What are those 'cut' commands supposed to do?  The second one is certainly
incorrect, as, to quote the 'cut' manpage:

     Either the -b, -c, or -f option must be specified.


Your next problem is that you're confusing *naming* a variable with
*expanding* a variable.  The *only* time you use a dollar sign is when
you want to interpolate the value of the variable into the command.
When you're assigning to a variable, you don't use the dollar sign.


And what happends if $RECEPTOR is in Cc: or in Bcc:

Your final problem is that you're trying to recover the envelope
recipient address from the header, which is impossible in the general
case.  If someone bcc's one of the aliases, then *none* of the aliases
will appear in the header.  You may hear suggestions about looking for
the phrase "for <address>" in the Received: headers, but that won't
solve your problem.  If you're invoking procmail via aliases then you
should just pass the name of alias to procmail via the command line.
If you're invoking procmail with the -m flag currently, then you can
just add the alias right after the name of the procmailrc:

        somealias: "|/usr/local/bin/procmail -m /some/procmailrc somealias"

If you're not using the -m flag, then you can use the -a flag to pass
in the information:

        somealias: "|/usr/local/bin/procmail -a somealias /some/procmailrc"


Then in the procmailrc, just say:

        RECEPTOR = $1

and forget about trying to use formail (and cut) to get the address.
To perform different actions depending on the value of RECEPTOR, use
the "var ??" condition format:


        :0
        * RECEPTOR ?? ^^somealias^^
        ! finalN1 finalN2


If you're 'routing' email, then ^TO_ is almost certainly the wrong
thing to use.

BTW: I don't think RECEPTOR is the word you were looking for.  To quote
webster:

        Word: receptor
        re-cep-tor \ri-'sep-ter\ n
        (1900)
        :RECEIVER: as
        a: a cell or group of cells that receives stimuli: SENSE ORGAN
        b: a chemical group or molecule in a plasma membrane or cell interior
             that has an affinity for a specific chemical group, molecule, or
             virus

Perhaps you meant "recipient" or "receiver" (I prefer the former).

Philip Guenther

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