On Fri, 19 Feb 1999 01:45:56 -0000, "Mike Watkins"
<mwatkins(_at_)promotion4free(_dot_)com> wrote:
can pass the e-mail address in the From: header onto a perl script?
I know this is done with formail, but can't figure out how.
Perl inherits Procmail's environment, so you can simply say
FROM=`formail -zxFrom:`
:0
| perl ...
and access it via $ENV{"FROM"} in the Perl script. Of course, if you
actually want the script to be useful outside of Procmail, too, it's
better to pass in the From: address as a command-line parameter:
FROM=`formail -zxFrom:`
:0
| perl ... "$FROM"
You don't really need formail for this, but let's not get into how to
use \/ and MATCH to get at the contents of the From: field as this is
not really what you were asking about. Read on.
All I need is a way to extract the e-mail address from the From:
header, and pass it onto a perl script.
This is not really it then. formail -zxFrom: will return the contents
of the entire From: field. Getting this stripped down to just the
email terminus is conventionally done like so:
FROM=`formail -rtzxTo:`
(see the FAQ[1] for why this works) but this has the potential problem
that formail will prefer the contents over e.g. Reply-To: over the
contents of From:. If that's a problem, you can zap unwanted fields
with -I, like this:
FROM=`formail -IResent- -IReply-to -rtzxTo:`
The exact preference order with -r and -rt is not really documented
anywhere except in the source, although I have a web page with this
information available[2].
/* era */
PS. Your domain name looks like obvious spam filter bait. :^/
[1] <http://www.iki.fi/~era/procmail/mini-faq.html>
[2] <http://www.iki.fi/~era/procmail/formail.html>
--
.obBotBait: It shouldn't even matter whether <http://www.iki.fi/~era/>
I am a resident of the state of Washington. <http://members.xoom.com/procmail/>