Re: [Exim] environment vars & extension addresses

Αρχική Σελίδα
Delete this message
Reply to this message
Συντάκτης: Jason R. Mastaler
Ημερομηνία:  
Προς: exim-users
Αντικείμενο: Re: [Exim] environment vars & extension addresses
Philip Hazel <ph10@???> writes:

> Exim doesn't put all of this information in the environment, but the
> information is available in Exim variables which you can pass over
> to your script as arguments. For example, in the .forward file you
> could have
>
> |/name/of/script $sender_address $local_part $local_part_suffix
>
> and the information you require will be put in the first three
> arguments that are passed to the script.


Do I have to add something to my Exim config to get those variables
expanded in the .forward? It doesn't seem to work for me.

To test, my .forward contains:
|/home/johndoe/envwrite $sender_address $local_part $local_part_suffix

/home/johndoe/envwrite contains:
#!/usr/local/bin/bash
echo $* > ~/env

After sending a message to johndoe, /home/johndoe/env contains:
$sender_address $local_part $local_part_suffix

So the arguments are passed in literally, not expanded.

Also, is there a way to set environment variables in the .forward
before invoking the pipe command? Something analogous to:

SENDER="$sender_address"
RECIPIENT="$local_part@$domain"
EXTENSION="$local_part_suffix"
|/name/of/script

This way I wouldn't have to modify my program at all.

> I think I'd like to keep the environment small, because otherwise
> the requirement to put more and more information in it is very
> open-ended.


I understand. You might at least want to look over what Postfix and
qmail put in the environment for reference.

Postfix: http://www.postfix.org/local.8.html
qmail: http://www.qmail.org/man/man8/qmail-command.html

> However, I can see a case for LOCAL_PART_PREFIX and
> LOCAL_PART_SUFFIX so that the entire recipient address is available
> by that means.


Great, thanks for being open-minded about this. I also think
RECIPIENT (envelope recipient address, local@domain) would be a
worthwhile addition so those needing that information wouldn't have to
concatenate $LOCAL_PART and $DOMAIN to get it.