Re: [exim] supplying headers_add from an lsearch won't work

トップ ページ
このメッセージを削除
このメッセージに返信
著者: Phil Pennock
日付:  
To: Don Walker
CC: Exim Users
題目: Re: [exim] supplying headers_add from an lsearch won't work
On 2010-07-30 at 09:16 -0500, Don Walker wrote:
> where the file mladdhdr contains entries like
>
> mylist: To: aaaaa@??? \n\ From: xxxxx@???
>
> I cannot get the content presented by the lsearch to show up in a format
> acceptable to the router's headers_add option. I have tried many
> variations in formatting the To: and From: header content, including
> separate lines for each header. A single header works fine, as in
>
> mylist: To: aaaaa@???
>
> but specifying multiple headers will not generate the desired format of
>
> headers_add  To: aaaaa@??? \n\
>      From: xxxxx@???

>
> which works if manually coded in the router.


The \ at the end of the line is for the parser of the config file, to
join the items into one line. By the time that the data makes it into
headers_add, that \ has been removed.

Lena is right in pointing towards ${expand:...} but failed to point out
that this is slightly dangerous, depending on how data makes it into
those files, as it causes $expansions to take place, including
${run{..}}.

Personally, I suggest using a different storage format, such as cdb,
which will let you store arbitrary data for a given key, and then store
literal newlines as part of the data.

Failing that, if a newline is the only substitution/escape which you
want, you can do it with ${sg{data}{regexp}{replacement}}. Beware that
\ will be interpreted both by the config parser and by the regexp
engine, so since you need to match a literal \ you can either use \\\\n
for the regexp, or \N\\n\N -- the latter is clearer as to what's going
on.

${sg{${lookup {mylist}lsearch{/wherever}}}{\N\\n\N}{\n}}

-Phil