procmail
[Top] [All Lists]

Re: formail options

1998-05-04 23:36:10
On Mon, 4 May 1998, Dave Robbins wrote:

FROM=`formail -rzxTo:`        

It gives us, according to what I understand, the address in 
the From-space line.

Not really. That gets a likely reply address, based on a heirarchy that I
don't think the manpage covers. If you want the address from the From_
line (the 'postmark'), then you have to do a bit more using formail. 

        FROM_=`formail -X"From "|formail -rzxto`

To break the back-ticked command down into steps:

        1)      Extract the "From " line, using formail.
        2)      Pipe the output to formail again.
        3)      Make up a reply-header, taking the input line as the
                sender we're replying to..
        4)      Extract the address in the new "To:" field, 
                dropping leading and trailing whitespace.

That method restricts what input content formail gets to see for the final
extraction of the address. 

I like to use sed for the same job:

        FROM_=`sed -e '2,$d' -e 's/^From //' -e 's/ .*//'`

I'm under the impression that this is more efficient. But if you can, why
not just use procmail's MATCH var and get the address from the $MATCH?
Then you won't be forking the shell required by sed or formail.

                :0
                * ^^From( )\/[^  ]+
                { FROM_=$MATCH }

David Hunt


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