MIMEMultipart() and CRLF vs RFC 2046

alf ask at me
Thu Oct 5 23:52:41 CEST 2006


according to rfc2046, line breaks in MIME are CRLF. However python just 
uses LF like in the following example:

from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText

msg = MIMEMultipart()
msg['Subject'] = 'Our family reunion'
msg['From'] = 'a at a.b'
msg['To'] = 'c at x.y'
msg.epilogue = ''


print `msg.as_string()`

'Content-Type: multipart/mixed; 
boundary="===============1018679223=="\nMIME-Version: 1.0\nSubject: Our 
family reunion\nFrom: a at a.b\nTo: 
c at x.y\n\n--===============1018679223==\nContent-Type: text/plain; 
charset="us-ascii"\nMIME-Version: 1.0\nContent-Transfer-Encoding: 

Any insight why does it not stick to standard. I also checked parsing 
and it seems to accept both CRLF and LF.

Thx, alfz1

More information about the Python-list mailing list