Mailing List Archive

qmail-alias env vars?
Jeff T. Carneal <jeff@apex.apex.net> asks:
>
>I'm trying to setup a perl script ala qmail-command which will only allow
>certain addresses to send to a particular address. For example,
>jeff-blah@apex.net will bounce everybody that sends to it except for me
>(jeff@apex.net).
>
>Now, I understand that qmail-alias provides environment variables to a
>command in .qmail (such as |my-script.pl). The one I'm interested in
>(obviously) is the SENDER environment variable. However, I can't seem to
>get my script to find it. What exactly do I have to do to get to that
>variable?
>

This sounds like more of a Perl question than a qmail one, but the
answer is fairly simple. In Perl, environment variables are found
in the %ENV hash (associative array). So a statement like:

$sender_address = $ENV{'SENDER'};

should retrieve it for you.

-Greg
--
Greg Andrews West Coast Online
Unix System Administrator 5800 Redwood Drive
gerg@wco.com Rohnert Park CA 94928
(yes, 'greg' backwards) 1-800-WCO-INTERNET
Re: qmail-alias env vars? [ In reply to ]
On Sun, 16 Feb 1997, Greg Andrews wrote:

> Jeff T. Carneal <jeff@apex.apex.net> asks:
> >
> >I'm trying to setup a perl script ala qmail-command which will only allow
> >certain addresses to send to a particular address. For example,
> >jeff-blah@apex.net will bounce everybody that sends to it except for me
> >(jeff@apex.net).
> >
> >Now, I understand that qmail-alias provides environment variables to a
> >command in .qmail (such as |my-script.pl). The one I'm interested in
> >(obviously) is the SENDER environment variable. However, I can't seem to
> >get my script to find it. What exactly do I have to do to get to that
> >variable?

> This sounds like more of a Perl question than a qmail one, but the
> answer is fairly simple. In Perl, environment variables are found
> in the %ENV hash (associative array). So a statement like:
>
> $sender_address = $ENV{'SENDER'};

Well, that's what I thought too, but that's not how life works. For the
interested (and to my chagrin) I found the answer about 10 minutes after
posting (sorry).

$sender = $ENV{"SENDER"} doesn't work because there is not environment
variable "SENDER". Here's what does work:

In your .qmail-whatever file, put the command like this:

| my-script.pl "SENDER"

and then get it from $ARGV. It won't work the other way, so don't even
try it :)

-------------------------------------

Now, if anybody can help me with getting the actual message from standard
input, I'd appreciate that. I can't seem to get it to find the correct
input...

'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'
`' Jeff Carneal / Sys Admin \ Apex Internet `'
`' jeff@apex.net http://www.apex.net `'
`' The opinions expressed above aren't really mine. They belong to `'
`' someone else who also refuses to take responsibility for them. `'
'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'