Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4a.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.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'socket': 0.07; 'subject:position': 0.09; 'cc:addr:python-list': 0.11; 'better:': 0.16; 'burak': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hack,': 0.16; 'sockets': 0.16; "someone's": 0.16; 'subject:Add': 0.16; 'top-level': 0.16; 'wrote:': 0.18; 'discussion': 0.18; 'pieces': 0.19; 'thu,': 0.19; 'cc:addr:python.org': 0.22; '(by': 0.24; 'module,': 0.24; 'tend': 0.24; 'header': 0.24; 'cc:2**0': 0.24; 'this:': 0.26; 'header:In- Reply-To:1': 0.27; 'am,': 0.29; 'liable': 0.30; 'message- id:@mail.gmail.com': 0.30; 'work.': 0.31; 'supposed': 0.32; "i'd": 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; 'does': 0.39; 'how': 0.40; 'new': 0.61; "you're": 0.61; 'name': 0.63; 'more': 0.64; 'taking': 0.65; 'side': 0.67; 'hang': 0.67; 'examples.': 0.84; '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=Uq7Lr1YjiDEXUJ1flvxwojiTEhxcIvbpxfVlCZv6BpA=; b=t9KG9hOslykR6s6H9vlePwBywc+Sg6PsA+P434D9+xknOFxz1o5wS24OP7CTS5NSOA GlK+Os/qEFPeRNSQQo4sJCq6X23FONgEwaF2fG2To0z1oDZCLJ8Iy0izg9kmSn2I+Sw5 4+MeUYIWLWotByc00EB0JtFOcM/m44Ij0EiYFl/U5zA8nvWpdWLo+d7/aT9Qt5GSjjqR tMqTwq+ayB9JxH3HzMx3sWOi8Qdl6DHexZJ4ieLbdSfAXsr7EEwOrIwTzJ+epxbjXM9A ikmkBYMhhrFYHMOZmABbiER55Y8udqKVeCET/f3yyX1px3BwkeJiKaodhL7MnGGYNPxW fpOw== MIME-Version: 1.0 X-Received: by 10.52.93.201 with SMTP id cw9mr868481vdb.80.1399475501936; Wed, 07 May 2014 08:11:41 -0700 (PDT) In-Reply-To: <536A4BF7.6040000@arskom.com.tr> References: <536A4BF7.6040000@arskom.com.tr> Date: Thu, 8 May 2014 01:11:41 +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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1399475504 news.xs4all.nl 2935 [2001:888:2000:d::a6]:34122 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:71029 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. (By the way, side point: I tend to avoid calling a socket "socket", as that's the name of the module. I'd use "sock" in examples. Otherwise someone's liable to go digging for a top-level method "write" in the "socket" module, and get confused. And then think that sockets are confusing, which they're not!) ChrisA