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

Ian Kelly ian.g.kelly at gmail.com
Wed May 7 18:29:34 EDT 2014


On May 7, 2014 9:13 AM, "Chris Angelico" <rosuav at gmail.com> wrote:
>
> 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.

Alternatively, you could use a BytesIO to prepend the Received header to
the raw data *before* you parse it with the email module.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140507/3f2ab681/attachment.html>


More information about the Python-list mailing list