On 2010-07-30 at 09:16 -0500, Don Walker wrote:
> where the file mladdhdr contains entries like
> 
> mylist:  To: [email protected] \n\  From: [email protected]
> 
> 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: [email protected]
> 
> but specifying multiple headers will not generate the desired format of
> 
> headers_add  To: [email protected] \n\
>      From: [email protected]
> 
> 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

-- 
## List details at http://lists.exim.org/mailman/listinfo/exim-users 
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/

Reply via email to