Manlio Perillo <[EMAIL PROTECTED]> wrote: > >The problem is this code: > > >>> import email.Message > >>> msg = email.Message.Message() > >>> msg["subject"] = "email bug" > >>> msg["from"] = "Manlio Perillo" > >>> print repr(msg.as_string()) >'subject: email bug\nfrom: Manlio Perillo\n\n' > >Why line ending is '\n' and not '\r\n' ? >RFC 2822 says that the delimiter must(?) be '\r\n'.
Because all you have there is a string. It doesn't have anything to do with RFC 2822. \n is probably the safest cross-platform way to represent a newline in a Python string. Note that smtplib, which DOES have to worry abouot RFC 2822 compliance, will replace all standalone \r and \n characters with \r\n. >email.Header has a bug: > >this code causes an infinite recursion: > > >>> from email.Header import Header > >>> h = Header('multiline header', 'iso-8859-1', maxlinelen=4) > >>> e.encode() I'm not sure I would call that a bug. I'd call that a usage error; you've asked it to accomplish something that cannot be done. However, it is true that _split has enough information to diagnose this. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list