I have a milter - which I need to delete some headers in incoming
emails... I see I can use smfi_chgheader() in the milter eom (End of
Message) callback to do this.
However, that only removes a single instance of a header, e.g. if the
incoming email has headers such as:
"
X-SomeHeader: Hello
X-SomeHeader: Goodbye
X-SomeHeader: YetAgain
X-SomeHeader: LastOne
"
Calling:
smfi_chgheader( ctx, "X-SomeHeader", 1, NULL )
Only removes the first header.
A workaround I've come up with is to 'count' the headers in as they
arrive in the milter header callback, so for the example above - we'd
have a count of 4, we'd then call smfi_chgheader() with a hdrirdx of
1, then again with a hdridx of 2, then 3 - then 4.
Repeatedly calling it with a hdridx of 1 doesn't remove additional
headers.
Can someone confirm the above is correct? - i.e. There is no 'delete
all headers with a headerf value of ..' type functionality, and that
instead calling smfi_chgheader() multiple times (once with each
occurence number of the header we want to delete) is acceptable?
Thanks,
-Jon
> Can someone confirm the above is correct? - i.e. There is no 'delete
> all headers with a headerf value of ..' type functionality, and that
> instead calling smfi_chgheader() multiple times (once with each
> occurence number of the header we want to delete) is acceptable?
We do it that way in MIMEDefang. It was the only way I could find
to do it.
Regards,
David.
Oh well - one by one removal it is then... As they can only be removed
at EOM - it's a bit of a pain as you have to 'count them in' then
remove them...
Having remove return either 'yes deleted it' or not would have been
good - you could just keep calling it until it either returns "none
deleted" or an error.
Thanks for the reply,
-Jon
: Oh well - one by one removal it is then... As they can only be removed
: at EOM - it's a bit of a pain as you have to 'count them in' then
: remove them...
: Having remove return either 'yes deleted it' or not would have been
: good - you could just keep calling it until it either returns "none
: deleted" or an error.
Based on reading
sendmail-8.14.3/sendmail/milter.c:milter_changeheader() that is the
only way to do it. You would have to modify this function to loop when
idx = 0 (or something). Perhaps put in a change request or send a
patch.