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

Chris Angelico rosuav at gmail.com
Wed May 7 11:11:41 EDT 2014


On Thu, May 8, 2014 at 1:06 AM, Burak Arslan <burak.arslan at 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.

(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



More information about the Python-list mailing list