to extract "From: " address properly

I am using a recipe to catch the email address in "From: " line to build a "white list", with this to extract the address: FROM=`formail -zX From: | formail -c -rt -xTo:` or FROM=`formail -zX From: | formail -zrx To:` or FROM=`formail -rtzxTo:` it works fine for some of the time, but once a while it ends up with a "foo@bar". I wonder why... (is it sometimes the top of the "From " line?) Zhiliang

On 2019-04-09 23:19, Zhiliang Hu wrote:
I am using a recipe to catch the email address in "From: " line to build a "white list", with this to extract the address:
FROM=`formail -zX From: | formail -c -rt -xTo:` or FROM=`formail -zX From: | formail -zrx To:` or FROM=`formail -rtzxTo:`
procmailex mentions: FROM='formail -rt -xTo:' Test your expressions: echo -en 'From foo1\nFrom: foo2\nTo: bar\nCc: baz\n' |formail -rt -xTo: foo2
it works fine for some of the time, but once a while it ends up with a "foo@bar". I wonder why... (is it sometimes the top of the "From " line?)
See also https://rvtol.home.xs4all.nl/procmail/basic/pm/ which doesn't use formail. Be prepared to handle encoded headers (base64, quoted-printable). (see the pure-procmail-decoders, or MIME in procmailex) procmailex also mentions: DEFAULT=| which is good for debugging. -- Greetings, Ruud
participants (2)
-
Ruud H.G. van Tol
-
Zhiliang Hu