Re: [EXIM] Headers add/remove

Page principale
Supprimer ce message
Répondre à ce message
Auteur: Philip Hazel
Date:  
À: John Horne
CC: exim-users
Sujet: Re: [EXIM] Headers add/remove
On Mon, 3 Aug 1998, John Horne wrote:

> I had something similar in the system filter to:
>
>    headers remove Reply-to
>    headers remove From

>
>    headers add "From: ${lookup {${substr_4:${local_part:$h_To:}}} lsearch
>                          {replies} {$value} {postmaster@???}}\\n"

>
>    headers remove To
>    freeze


(Minor point) You shouldn't have \\n in that string; it should be
\n; as it stands, the string-reading code turns it into \n and the
string expansion code turns that into just n.

I have tried this, and it seems to work for me. Are you sure you have
got that substr_4 correct? It takes the whole of the local part,
starting at offset 4. (Note: you can do some testing of this kind of
thing by making use of the logfile and logwrite commands.) [And I
presume that where you have "replies" you actually had an absolute file
name...]

> However, the file lookup fails. If I remove the 'headers remove To' line then
> it works. Am I missing something here or isn't the script being executed
> sequentially?


That seems very strange. Are you sure that was what happened? It worked
for me with and without the 'headers remove To' line.

> Secondly, since the above results in no recipients being shown by my mail
> agent, I thought I would add a blank Cc: header. I added to the end the line
> 'headers add "Cc:"'. I ended up with:
>
>       Cc: From: postmaster@???

>
> and no recipient address being shown (since the From: had now gone).

         ^^^^^^^^^
         sender? 


The headers add command doesn't at present automatically put a newline
on the end of what it adds. I think it probably should, and have noted
this as a small buglet (but since I have just cut 2.02 it won't get
fixed immediately).

> If I changed it to 'headers add "Cc:\n"' then I get:
>
>       Cc:
>       Cc: 


Are you sure it didn't go through the filter twice?

> I also noticed that since the message was frozen eximon showed the From:
> header to have been rewritten (using the 'headers' mouse action on the
> message) and with the correct (!) address from the file lookup. When I forced
> the message to be delivered it appeared as 'From: postmaster@???'.


... but that would have gone through the filter again ... and since you
removed the To line the first time ...

Take a look at the "first_delivery" condition (chapter 42) which can be
helpful in this situation.

There does however, seem to be a problem with the explicit adding of headers
which Exim recognizes specially, but I don't think that is relevant
here.

-- 
Philip Hazel            University of Cambridge Computing Service,
ph10@???      Cambridge, England. Phone: +44 1223 334714.




--
*** Exim information can be found at http://www.exim.org/ ***