Author: Phil Pennock Date: To: Kirk Friggstad CC: exim-users Subject: Re: [exim] Filter question - getting "envelope-to" header via pipe?
On 2011-07-22 at 14:02 -0600, Kirk Friggstad wrote: > Everything works pretty much as expected - incoming mail gets saved in the mailattachments directory, and the perl script fires and gets the entire message on STDIN with no problems. However, I haven't been able to find how to find out the original address the message is sent to. In the saved copy, there is an additional header called "Envelope-to" that contains the original address, but this header doesn't appear to exist in the message as delivered to STDIN. I haven't been able to find the original address in any of the environment variables, and none of the string expansions that I've tried seems to have it either. I can't rely on the "To:" field either, as most of the messages are being forwarded from another account on another mail server.
Find the "address_pipe" Transport definition; either change it, or copy
it to a new name and change the value of "pipe_transport" on the
"userforward" Router to reference the new name.
Look at the "address_file" Transport, see the "envelope_to_add" option?
That's what you want on the pipe transport used by this filter setup.
> First question - is there a simple string expansion or some other place that I can pass the envelope-to information to the pipe script (as a command-line argument, etc.)?
Loosely, you construct from $local_part@$domain -- but you might want
the $original_* variants, might want to deal with affices, etc. I
suspect that just setting envelope_to_add on the relevant pipe transport
does everything you really want.
> Second question - is there a better way to get all mail for a particular domain to feed through a custom script (that will also be able to pass along the envelope-to information) besides what I'm doing (catch-all to local account, .forward with pipe)?
"Better" is a matter of taste. Custom Routers, with "unseen", etc. If
you understand what your current setup does then that's better than a
setup you have to study to understand, so probably best to stick with
what you have.