Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.034 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'subject:position': 0.09; '*before*': 0.16; '9:13': 0.16; 'better:': 0.16; 'burak': 0.16; 'hack,': 0.16; 'subject:Add': 0.16; 'wrote:': 0.18; 'discussion': 0.18; 'pieces': 0.19; 'thu,': 0.19; 'email addr:gmail.com>': 0.22; 'parse': 0.24; 'header': 0.24; '>': 0.26; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'work.': 0.31; 'supposed': 0.32; 'raw': 0.33; "i'd": 0.34; 'could': 0.34; 'skip:s 30': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'module.': 0.36; 'method': 0.36; 'subject:?': 0.36; 'two': 0.37; 'skip:& 10': 0.38; 'to:addr :python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'new': 0.61; "you're": 0.61; 'more': 0.64; 'taking': 0.65; 'hang': 0.67 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:to :content-type; bh=zEpP/Knn+CRG4N4YSO+pKnGv/qN9LQUcaVBUFUdjFVg=; b=cU0WjI2pzFZUmT12hqqkzCXt9VhR+vSk7k9b3CPWqTu61OOuytWZf2mr4MIEQAcvXb T54c0UF6QQKscMYg3TgNZBJlnu0L1KOfziVWihcFdH0c65ETYMCM87wKgullo5tnz7ZN fiokKiiyQ7nMLWN4n7mDfsYcAEfd9BF3IabVmpPFJAtXRp+iy8kkSDyjBU8ISvxLlW6m b33XhBSvgcMLcu5mEkvLM9KL/xmDv2r2aSn/vN6mz9+pftTYq+cYb2rVyWMDGY+L5aKs fvXhuHDF/cLAXbOA84QVD1Xceyo4q8dr0gjoUTHFbxZ7cNssLJvpnuy5CtKNFvXLJ85O v59Q== MIME-Version: 1.0 X-Received: by 10.66.171.76 with SMTP id as12mr23589811pac.52.1399501774246; Wed, 07 May 2014 15:29:34 -0700 (PDT) In-Reply-To: References: <536A4BF7.6040000@arskom.com.tr> Date: Wed, 7 May 2014 16:29:34 -0600 Subject: Re: Add "Received:" header to email msg in correct position? From: Ian Kelly To: Python Content-Type: multipart/alternative; boundary=047d7bea441a1dda9d04f8d6e61f 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: 53 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1399502104 news.xs4all.nl 2975 [2001:888:2000:d::a6]:37428 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:71059 --047d7bea441a1dda9d04f8d6e61f Content-Type: text/plain; charset=UTF-8 On May 7, 2014 9:13 AM, "Chris Angelico" wrote: > > On Thu, May 8, 2014 at 1:06 AM, Burak Arslan wrote: > > Seeing how discussion is still going on about this, I'd like to state > > once more what I said above in other words: You just need to do this: > > > > "Received: blah\r\n" + message.to_string() > > > > or better: > > > > socket.write("Received: blah\r\n") > > socket.write(message.to_string()) > > > > And again, this is not a hack, this is how it's supposed to work. > > Yes, that method does work... if you're taking it in and sending it > right out again. But it means you have to hang onto two pieces of data > - the message and the new Received header - until you write it to a > file/socket. Alternatively, you could use a BytesIO to prepend the Received header to the raw data *before* you parse it with the email module. --047d7bea441a1dda9d04f8d6e61f Content-Type: text/html; charset=UTF-8


On May 7, 2014 9:13 AM, "Chris Angelico" <rosuav@gmail.com> wrote:
>
> On Thu, May 8, 2014 at 1:06 AM, Burak Arslan <burak.arslan@arskom.com.tr> wrote:
> > Seeing how discussion is still going on about this, I'd like to state
> > once more what I said above in other words: You just need to do this:
> >
> > "Received: blah\r\n" + message.to_string()
> >
> > or better:
> >
> > socket.write("Received: blah\r\n")
> > socket.write(message.to_string())
> >
> > And again, this is not a hack, this is how it's supposed to work.
>
> Yes, that method does work... if you're taking it in and sending it
> right out again. But it means you have to hang onto two pieces of data
> - the message and the new Received header - until you write it to a
> file/socket.

Alternatively, you could use a BytesIO to prepend the Received header to the raw data *before* you parse it with the email module.

--047d7bea441a1dda9d04f8d6e61f--