How do I generate a multipart/mime message with correct CRLF in Python?

What about a simple hack message. As_string(). Replace('\n', '\r\n')?

Inelegant, but should work (and a bug report should be entered at the Python tracker).

Thought of that, but if there's \n characters in the body (which is a PNG file, so straight binary) then this will screw it up. AFAICT, the encode_7_or_8bit doesn't do anything clever to byte-stuff \n characters. – Malcolm Box Jun 22 '10 at 12:55 Oh there's already a bug here: bugs.python.Org/issue1349106 It's been open since 2005 and for reasons I don't understand seems to be being resisted.

– Malcolm Box Jun 22 '10 at 12:57 @Malcolm, by the time you replace newlines, the body's already been coded in some mail-acceptable way, which "straight binary" is most definitely not -- it would violate many RFCs. An encoding that doesn't actually and carefully "modify the payload" to make it RFC-compliant is unacceptable, and using it is your bug, not Python's -- use encode_base64 for binary payloads! – Alex Martelli Jun 22 '10 at 15:41 Actually, binary is entirely MIME compliant as a transfer encoding - see e.g. Tools.ietf.

Org/html/rfc2045#section-5.2 - but not for transmission over SMTP. But I'm not sending this over SMTP but over HTTP, which is perfectly happy to ship binary data. The bug is definitely Python's - it is assuming that all MIME will be transport encoded e.g. By the SMTP layer, but that isn't the case.

– Malcolm Box Jun 23 '10 at 14:06 @Malcolm, you're right, by the letter of the RFCs. However, you did ask "what have other people done", and base64 encoding + the hack I mentioned is no doubt the popular workaround. – Alex Martelli Jun 23 '10 at 15:42.

This was a bug in Python that has now been fixed: hg.python.org/lookup/r85811 It should now be possible to use the MIME libraries over non-email transports and have sensible things happen.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions