When constructing -> parsing -> re-constructing a message it is difficult to re-create the same message since message.WriteTo() iterates through a map and the order of headers is random. In some instances the order of the headers matters such as DKIM and Received headers. Would you be interested in a PR to support this? If so, I see it two ways:
1) Use a slice instead of a map (like attachments) to preserve order. Unfortunately, message.SetHeaders signature will change.
2) Change the type of header from map[string][]string to something like map[string]*hValue where hValue is something like:
type hValue struct {
values []string
order int
}
order increments each time a header gets added. Then message.WriteTo will sort headers by order when writing headers.
When constructing -> parsing -> re-constructing a message it is difficult to re-create the same message since
message.WriteTo()
iterates through a map and the order of headers is random. In some instances the order of the headers matters such as DKIM and Received headers. Would you be interested in a PR to support this? If so, I see it two ways:1) Use a slice instead of a map (like attachments) to preserve order. Unfortunately,
message.SetHeaders
signature will change.2) Change the type of header from
map[string][]string
to something likemap[string]*hValue
wherehValue
is something like:order
increments each time a header gets added. Thenmessage.WriteTo
will sort headers byorder
when writing headers.Let me know what you think, thanks.