procmail
[Top] [All Lists]

Re: sending valid 'from' field to perl script.

1996-06-07 10:09:34
At 07:20 96-06-07, Wotan wrote:

On Thu, 6 Jun 1996, Spiderline Consulting wrote:

hello.  I have been searching archive's for the answer, but nothing yet..

I'm looking for a way to have procmail pick out the original sender of a
the message and then pass it along, with the body of the message, to a
perl script.

Perhaps there is a way to pick out the valid field entries (ie, from, to,
subject) and then send along with the message?

If not, anyone who can write the section of perl code which *can* do
this, please let me know..

What, exactly are you trying to do?

This is a perl script I use [deleted]

FWIW, this script won't work with continued headers (i.e. headers that
span multiple lines).  (It also isn't written in the most optimal
way...)  Procmail knows how, though....

Use formail to pull out the header of interest into variables inside
the procmailrc script.  Then just pipe the body to your perl script.
The procmail variables will be available to the perl script in the %EVN
array (they're exported environment variables).  That way you don't
have to worry about quoting, continuation lines, ...

Untested pseudo code:
:0
#whatever conditions you need
{
    :0
    * ^from:[   ]*\/.*  # that's a space and a tab in the brackets
    {
        FROM=$MATCH
    }

    # or, let formail do the stripping at the cost of a process:
    SUBJECT=`formail -z -x "Subject:"`

    :0 b
    |my_perl_script
}

As for "original sender", if you mean to whom a reply would go, use
something like:
    AUTHOR=`formail -rzt -x "to:"`

In your Perl script, reference the info as, e.g.:
    $ENV{ 'AUTHOR' };

Good luck!

--Hal
Hal Wine <hal(_at_)dtor(_dot_)com>     voice: 510/482-0597


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