Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news.linkpendium.com!news.linkpendium.com!panix!not-for-mail From: Grant Edwards Newsgroups: comp.lang.python Subject: Re: Add "Received:" header to email msg in correct position? Date: Tue, 6 May 2014 14:19:28 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 27 Message-ID: References: NNTP-Posting-Host: dsl.comtrol.com X-Trace: reader1.panix.com 1399385968 9007 64.122.56.22 (6 May 2014 14:19:28 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Tue, 6 May 2014 14:19:28 +0000 (UTC) User-Agent: slrn/1.0.1 (Linux) Xref: csiph.com comp.lang.python:70962 On 2014-05-06, Grant Edwards wrote: > On 2014-05-06, alister 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. I was looking in the message format RFCs, and as has already been pointed out, it's in the SMTP spec (RFC2821). Since there _is_ an RFC that specifically states you MUST prepend a header line to a message, this seems to be a hole in the email module... -- Grant Edwards grant.b.edwards Yow! If I am elected no one at will ever have to do their gmail.com laundry again!