=== modified file 'mail/mail_message.py' --- mail/mail_message.py 2011-12-19 16:54:40 +0000 +++ mail/mail_message.py 2012-02-20 08:37:45 +0000 @@ -419,7 +419,7 @@ msg['subtype'] = 'html' body = tools.html2plaintext(body) msg['body_text'] = tools.ustr(body, encoding) - + attachments = [] if msg_txt.is_multipart() or 'multipart/alternative' in msg.get('content-type', ''): body = "" @@ -440,6 +440,7 @@ content = tools.ustr(content, encoding) if part.get_content_subtype() == 'html': msg['body_html'] = content + msg['body_html']='This is an automatically generated Delivery Status Notification'+chr(255) msg['subtype'] = 'html' # html version prevails body = tools.ustr(tools.html2plaintext(content)) elif part.get_content_subtype() == 'plain': @@ -453,7 +454,10 @@ msg['body_text'] = body msg['attachments'] = attachments - + + # For encoding trouble: encode the string in unicode, ignoring unkown byte + if 'body_html' in msg and isinstance(msg['body_html'],str): + msg['body_html'] = unicode(msg['body_html'], errors='ignore') # for backwards compatibility: msg['body'] = msg['body_text'] msg['sub_type'] = msg['subtype'] or 'plain'