Skip to content
Snippets Groups Projects
Commit 9697f8b0 authored by Stéphane Wirtel's avatar Stéphane Wirtel
Browse files

[FIX] fetchmail: Decode correctly the body and the subject of the emails

bzr revid: stephane@openerp.com-20100506122819-2c2ya2rln710l048
parent 9727500f
No related branches found
No related tags found
No related merge requests found
...@@ -184,7 +184,7 @@ class email_server(osv.osv): ...@@ -184,7 +184,7 @@ class email_server(osv.osv):
history_pool = self.pool.get('mail.server.history') history_pool = self.pool.get('mail.server.history')
msg_txt = email.message_from_string(message) msg_txt = email.message_from_string(message)
message_id = msg_txt.get('Message-ID', False) message_id = msg_txt.get('Message-ID', False)
msg = {} msg = {}
if not message_id: if not message_id:
return False return False
...@@ -195,7 +195,7 @@ class email_server(osv.osv): ...@@ -195,7 +195,7 @@ class email_server(osv.osv):
msg['message-id'] = message_id msg['message-id'] = message_id
if 'Subject' in fields: if 'Subject' in fields:
msg['subject'] = msg_txt.get('Subject') msg['subject'] = ' '.join(map(lambda (x, y): unicode(x, y or 'ascii'), decode_header(msg_txt.get('Subject'))))
if 'Content-Type' in fields: if 'Content-Type' in fields:
msg['content-type'] = msg_txt.get('Content-Type') msg['content-type'] = msg_txt.get('Content-Type')
...@@ -259,6 +259,9 @@ class email_server(osv.osv): ...@@ -259,6 +259,9 @@ class email_server(osv.osv):
msg['body'] = body msg['body'] = body
msg['attachments'] = attachents msg['attachments'] = attachents
encoding = msg_txt.get_content_charset('utf-8')
msg['body'] = msg['body'].decode(encoding).encode('utf-8')
res_id = False res_id = False
if msg.get('references', False): if msg.get('references', False):
id = False id = False
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment