email package and line ending

Manlio Perillo manlio_perilloNO at SPAMlibero.it
Fri Dec 23 04:54:32 EST 2005


Regards.

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'.

The same problem is presente in email.Generator and email.Header (for 
multiline headers).


P.S.
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()




Manlio Perillo



More information about the Python-list mailing list