Re: [Exim] Passing variables to system filter

トップ ページ
このメッセージを削除
このメッセージに返信
著者: Philip Hazel
日付:  
To: Rock Scofield
CC: exim-users
題目: Re: [Exim] Passing variables to system filter
On Wed, 17 Sep 2003, Rock Scofield wrote:

> I need to have some dynamic data (out of a database) be used in the
> system filter. I cant seem to find any variables that will pass data
> between exim and the system filter.


Not clear what you mean by "between exim and the system filter". In what
place is the data obtained?

> So I added a header under the router that runs when the system filter
> runs


Also not clear, I'm afraid. The system filter runs before any routing is
done.

> reply_handler:
>    driver = accept
>    domains = *
>    local_part_prefix = itreply-
>    headers_add = X-Temp-Sendto: ${lookup pgsql{select mail_from from campaigns where campaignid = split_part('$local_part','-',1)}}
>    transport = reply_handler_pipe

>
> The 'reply_handler_pipe' goes to a python script that tracks replies,
> the system filter is to forward on the reply.


To you mean that the script submits a new message for the filter to pick
up on? That seems a strange way to do it. Why not get the script to
generate the reply to the right address? I think I'm not understanding
what you are trying to do here.

> here is the system filter...
>
> if
> $h_to: contains "itreply"
> then
> unseen deliver $h_X-Temp-Sendto
> endif
>
> this is what i get when it runs the filter
>
> 20390 2003-09-17 16:35:27 19zj1L-0005Iq-R4 Error in system filter: malformed address "" in filter file: empty address


How was the message that matches the $h_to: test generated? Did you just
send it? If so, that's what will happen. The sequence of events is

. The system filter is run ONCE.
. The routers are run once for each recipient address.
. The transports that are assigned by the routers are run.

> and if i put a static address in the filter, the X-Temp-Sendto header is not added even though it shows this in the debug


I think you are confused as to the order in which things happen.

> Any insight on why its not adding a header where the system filter can
> read it? Also if there are a set of variables that allows data between
> exim and the system.filter or the ability to use SQL in the system
> filter.


You can certainly use SQL in the system filter, since all strings are
expanded. However, something like:

deliver "${lookup pgsql{select mail_from from campaigns where campaignid = split_part('$local_part','-',1)}}"

will not work, because $local_part is not set. Why not? Because a
message may have many recipients, and the system filter is run just
once.

I think you are trying to use the system filter to achieve a routing
effect. This is not going to work. You should use a router for that
purpose. You can run per-address filters from redirect routers, but I
would guess that you don't even need to do that. Just use the
appropriate SQL lookup in a "data" option in a redirect router.



--
Philip Hazel            University of Cambridge Computing Service,
ph10@???      Cambridge, England. Phone: +44 1223 334714.
Get the Exim 4 book:    http://www.uit.co.uk/exim-book