maddy icon indicating copy to clipboard operation
maddy copied to clipboard

Add modifiers to rewrite headers

Open foxcpp opened this issue 5 years ago • 8 comments

See https://github.com/foxcpp/maddy/issues/158#issuecomment-551166366.

-- Original post:

This should not be used for relays (RFC 5321 prohibits modification of existing header fields) but is usually fine for submission servers. In case of submission, this is what people probably want when saying "replace sender" *. Need to think whether it may be useful for replace_rcpt too.

replace_sender this that {
  header on # probably default
}

* replacing only MAIL FROM command argument (as currently done by replace_sender) can invalidate DMARC alignment, btw.

foxcpp avatar Nov 06 '19 13:11 foxcpp

A useful feature implemented in postfix “header_checks REPLACE” allows you to change some fields in the header.

svanichkin avatar Nov 07 '19 07:11 svanichkin

One obscure feature of RFC 5322 is that it permits multiple addresses in the From field. In that case, simple regexp-based replacement may change only one address from the list unless applied repeately. I am not sure whether it is worth supporting (I don't think it is widely supported in clients).

So perhaps as an alternative it might be possible to introduce a set of modifiers for headers manipulation.

add_header KEY VALUE
replace_header KEY VALUE VALUE
replace_header KEY /VALUE/ VALUE
drop_header KEY

foxcpp avatar Nov 07 '19 16:11 foxcpp

I am sure that modifiers are the best option. replace_header FROM [email protected] [email protected]

svanichkin avatar Nov 11 '19 10:11 svanichkin

Blocked by emersion/go-message#75.

foxcpp avatar Mar 01 '20 02:03 foxcpp

Is this still blocked? If not, I'd be willing to try (partially) implementing this, if it's still desired and would be merged

ptrcnull avatar Jun 05 '23 22:06 ptrcnull

go-message still has a fairly restrictive interface for header manipulation. See discussion of the referenced PR.

foxcpp avatar Jun 13 '23 13:06 foxcpp