Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'receives': 0.04; 'indication': 0.09; 'subject:position': 0.09; 'yeah,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '2822': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'smtp,': 0.16; 'subject:Add': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'app': 0.19; 'module': 0.19; "python's": 0.19; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'headers': 0.24; 'mon,': 0.24; 'server.': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'on,': 0.29; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'went': 0.31; 'header,': 0.31; 'trivial': 0.31; 'figure': 0.32; 'supposed': 0.32; 'another': 0.32; '(most': 0.33; 'used,': 0.33; "i'd": 0.34; 'could': 0.34; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'there': 0.35; 'much.': 0.36; 'smtp': 0.36; "didn't": 0.36; 'subject:?': 0.36; 'clear': 0.37; 'being': 0.38; 'ends': 0.38; 'recent': 0.39; 'does': 0.39; "couldn't": 0.39; 'how': 0.40; 'read': 0.60; 'mentioned': 0.61; 'received:': 0.65; 'bottom': 0.67; 'edwards': 0.91; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=fdZANmzsmTeVU+jsOkmHa+hRKc2UtMj5C6dhfLeafbg=; b=C8eNxdmOJbCaPTxGrQOODupAeZt68QYi/DDqF3hKQZYLwPu4GTrmK5/9LbgRaHyw2G el83lJovE2/945unDgRqXckHoqkrNEAnzbId9zmIk4ACYFSlsxZ4k4NwRtbbtukooamI cW9dbnlrLHNhG77DyfotYfVix90M/a+rTNO+KrP8mbfpYP3m2UcJl4+sctmbrNCMG/WJ mpnU7sHxihzHIWokLJINY7v9XMgNuyZQyyuiKVF7O9p8AULGfMKa9b1FlqGH3OBs9JQX GvYs9x5ejGL69JMVmA4KrftM6x3HAdzmkXlJ3Q2sj7DCs0zOQMXPC1BjraA+K+l/wVl0 fr9Q== MIME-Version: 1.0 X-Received: by 10.58.28.204 with SMTP id d12mr61503veh.81.1399386384782; Tue, 06 May 2014 07:26:24 -0700 (PDT) In-Reply-To: References: Date: Wed, 7 May 2014 00:26:24 +1000 Subject: Re: Add "Received:" header to email msg in correct position? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1399386394 news.xs4all.nl 2971 [2001:888:2000:d::a6]:39585 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:70963 On Wed, May 7, 2014 at 12:15 AM, 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. 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