osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Add header at top with email.message


Jason Friedman <jsf80238 at gmail.com> writes:

> I suppose you already figured out that you can call __delitem__() to
> clear the headers and add them back in whatever order you like.

Well, this would mean saving all headers, deleting all, inserting my
own, and adding the saved original headers again.  Seems complicated.

> I'm interested in learning more about your use case.  Do you have a
> third party with fixed logic that requires the headers in a particular
> order?

Yes, RFC 5321, section 4.4[0] :)

> When an SMTP server receives a message for delivery or further
> processing, it MUST insert trace ("time stamp" or "Received")
> information at the beginning of the message content, as discussed in
> Section 4.1.1.4.

To trace the path a message went, those headers do need to be in a
particular order, or else they won?t make any sense.

[0]: https://tools.ietf.org/html/rfc5321#section-4.4