diff options
| author | ACH(OpenERP) <> | 2009-09-02 20:23:54 +0530 |
|---|---|---|
| committer | Jay (Open ERP) <jvo@tinyerp.com> | 2009-09-02 20:23:54 +0530 |
| commit | 460f3102bc7d2edd13b8efc302bb585d5a7e079a (patch) | |
| tree | 4dc72ebc5b07742edff483d250dc43093975fecf /bin/tools/misc.py | |
| parent | 40666e1316c447aac0ca69746dba3428e087376a (diff) | |
[FIX] Send Mail : Unicode error handled
lp bug: https://launchpad.net/bugs/421162 fixed
bzr revid: jvo@tinyerp.com-20090902145354-5b43k67lpbe513cj
Diffstat (limited to 'bin/tools/misc.py')
| -rw-r--r-- | bin/tools/misc.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/bin/tools/misc.py b/bin/tools/misc.py index 7760a9a851d..d8bd58bfcbd 100644 --- a/bin/tools/misc.py +++ b/bin/tools/misc.py @@ -331,7 +331,10 @@ def email_send(email_from, email_to, subject, body, email_cc=None, email_bcc=Non email_bcc = [] if not attach: - msg = MIMEText(body.encode('utf-8') or '',_subtype=subtype,_charset='utf-8') + try: + msg = MIMEText(body.encode('utf8') or '',_subtype=subtype,_charset='utf-8') + except: + msg = MIMEText(body or '',_subtype=subtype,_charset='utf-8') else: msg = MIMEMultipart() @@ -362,8 +365,10 @@ def email_send(email_from, email_to, subject, body, email_cc=None, email_bcc=Non msg['Message-Id'] = "<%s-tinycrm-%s@%s>" % (time.time(), tinycrm, socket.gethostname()) if attach: - msg.attach( MIMEText(body.encode('utf-8') or '', _charset='utf-8', _subtype=subtype) ) - + try: + msg.attach(MIMEText(body.encode('utf8') or '',_subtype=subtype,_charset='utf-8')) + except: + msg.attach(MIMEText(body or '', _charset='utf-8', _subtype=subtype) ) for (fname,fcontent) in attach: part = MIMEBase('application', "octet-stream") part.set_payload( fcontent ) |
