diff --git a/cgi-bin/webnotes/profile.py b/cgi-bin/webnotes/profile.py index b74fa08e5c..fc57cbabbb 100644 --- a/cgi-bin/webnotes/profile.py +++ b/cgi-bin/webnotes/profile.py @@ -162,12 +162,12 @@ class Profile: # update tab Profile webnotes.conn.sql("UPDATE tabProfile SET password=password(%s) WHERE name=%s", (pwd, profile[0][0])) - + self.send_email("Password Reset", "
Dear %s%s,
your password has been changed to %s
[Automatically Generated]
" % (profile[0][2], (profile[0][3] and (' ' + profile[0][3]) or ''), pwd), profile[0][1]) def send_email(self, subj, mess, email): import webnotes.utils.email_lib - + webnotes.utils.email_lib.sendmail(email, msg=mess, subject=subj) # update recent documents diff --git a/cgi-bin/webnotes/utils/email_lib/__init__.py b/cgi-bin/webnotes/utils/email_lib/__init__.py index abda347923..7d0572d46b 100644 --- a/cgi-bin/webnotes/utils/email_lib/__init__.py +++ b/cgi-bin/webnotes/utils/email_lib/__init__.py @@ -29,19 +29,18 @@ def sendmail(recipients, sender='', msg='', subject='[No Subject]', parts=[], cc email = EMail(sender, recipients, subject, reply_to=reply_to) email.cc = cc - - if msg: - if template: - msg = make_html_body(msg, template) + + if msg: + if template: + msg = make_html_body(msg, template).encode('utf-8') else: # if not html, then lets put some whitespace if (not '' in msg):
- msg = msg.replace('\n','
')
-
+ msg = msg.replace('\n','
')
footer = get_footer()
- msg = msg + (footer or '')
- email.set_text(html2text(msg))
- email.set_html(msg)
+ msg = msg + (footer or '')
+ email.set_text(html2text(msg))
+ email.set_html(msg)
for p in parts:
email.set_message(p[1])
for a in attach:
diff --git a/cgi-bin/webnotes/utils/email_lib/html2text.py b/cgi-bin/webnotes/utils/email_lib/html2text.py
index 66258d2477..d81c970546 100644
--- a/cgi-bin/webnotes/utils/email_lib/html2text.py
+++ b/cgi-bin/webnotes/utils/email_lib/html2text.py
@@ -447,7 +447,8 @@ def html2text_file(html, out=wrapwrite, baseurl=''):
return h.close()
def html2text(html, baseurl=''):
- return optwrap(html2text_file(html, None, baseurl))
+ txt = html2text_file(html.decode('utf-8'), None, baseurl)
+ return optwrap(txt.encode('utf-8'))
if __name__ == "__main__":
baseurl = ''
diff --git a/cgi-bin/webnotes/utils/email_lib/send.py b/cgi-bin/webnotes/utils/email_lib/send.py
index 2eff8ed9bc..52e4572459 100644
--- a/cgi-bin/webnotes/utils/email_lib/send.py
+++ b/cgi-bin/webnotes/utils/email_lib/send.py
@@ -16,6 +16,9 @@ class EMail:
"""
def __init__(self, sender='', recipients=[], subject='', from_defs=0, alternative=0, reply_to=None):
from email.mime.multipart import MIMEMultipart
+ from email import Charset
+ Charset.add_charset('utf-8', Charset.QP, Charset.QP, 'utf-8')
+
if type(recipients)==str:
recipients = recipients.replace(';', ',')
recipients = recipients.split(',')
@@ -36,7 +39,8 @@ class EMail:
Attach message in the text portion of multipart/alternative
"""
from email.mime.text import MIMEText
- part = MIMEText(message, 'plain')
+ msg = unicode(message, 'utf-8')
+ part = MIMEText(msg.encode('utf-8'), 'plain', 'UTF-8')
self.msg_multipart.attach(part)
def set_html(self, message):