Add "Received:" header to email msg in correct position?

Chris Angelico rosuav at gmail.com
Tue May 6 10:26:24 EDT 2014


On Wed, May 7, 2014 at 12:15 AM, Grant Edwards <invalid at invalid.invalid> wrote:
> On 2014-05-06, alister <alister.nospam.ware at ntlworld.com> wrote:
>> On Mon, 05 May 2014 19:51:15 +0000, Grant Edwards wrote:
>>
>>> I'm working on a Python app that receives an e-mail message via SMTP,
>>> does some trivial processing on it, and forwards it to another SMTP
>>> server.
>>>
>>> I'd like to do the polite thing and add a "Received:" header, but I
>>> can't figure out how to get Python's email module to add it in the
>>> correct place.  It always ends up at the "bottom" of the headers below
>>> From: To: etc.  It's supposed to go at the above all the Received:
>>> headers that where there when I received it.
>>
>> Is this required or just being polite?
>
> I couldn't find it in an RFC.  But every reference I could find that
> mentioned Received: headers did say that you read them from the bottom
> up (most recent is on top).

Yeah, I went looking for it in 2822 but didn't find much. After some
digging, found it in 2821, section 3.8.2. It's not dwelled on, but the
word "prepend" is used, which to my mind is a clear indication of
necessary ordering.

ChrisA



More information about the Python-list mailing list