RE: [Exim] how to rewrite

Página Principal
Apagar esta mensagem
Responder a esta mensagem
Autor: Fred Viles
Data:  
Para: exim-users
Assunto: RE: [Exim] how to rewrite
On 11 Feb 2004 at 0:57, Eli wrote about
    "RE: [Exim] how to rewrite":


| Fred Viles <> wrote:
| > On 10 Feb 2004 at 20:10, Michael Johnson wrote about
| >     "[Exim] how to rewrite":
| >
| >> ...
| >> I want to take a header from an incoming message, and copy the header
| >> to a different header with a different name.  For example, take the
| >> "List-Post:  address@???" header and copy the entry to give me
| >> "Reply-To:  address@???".  I suppose the rewrite should also
| >> check to see if there's already a Reply-To header.  I suppose that
| >> part could get to be quite tricky.
| >
| > How about this (untested), added to the appropriate router(s):
| >
| >   headers_add    = ${if and { \
| >             { !def:header_Reply-to: } \
| >             { def:header_List-Post: } \
| >               }    { Reply-To: $header_List-Post: } {} }

|
| That's not really a rewrite, but just adding another header


True, I was just trying to implement the actual example the OP gave
rather than the general case (it seemed easier!). I did make an
assumption, that by "should check to see if there's already a reply-
to" he meant "don't generate Reply-To if there already is one".

If you want to override an existing Reply-To:, if I read the spec
correctly you can also do it in the router with headers_add and
headers_remove (untested):

  # If both Reply-to and List-Post exist, copy original Reply-To
  # (optional)
  headers_add    = ${if and { \
        {def:header_reply-to:} {def:header_list-post:}\
            } {X-was-reply-to: $header_reply-to:} {} }
  # If List-Post exists, generate Reply-To from it
  headers_add    = ${if match {$header_list-post:} {\<mailto:(.*)\>} \
             {reply-to: <$1>} {} }
  # If both Reply-to and List-Post exist, remove original Reply-To
  headers_remove = ${if and { \
            {def:header_reply-to:} {def:header_list-post:}\
            } {reply-to} fail }


The various headers_add and headers_remove are remembered, and are
all processed at transport time (removes first).

- Fred