fixed Issue 1456:encoding in mail.send, thanks Corne

This commit is contained in:
mdipierro
2013-04-19 23:46:38 -05:00
parent c909af4a86
commit a2e118ec50
4 changed files with 13 additions and 8 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.4.6-stable+timestamp.2013.04.15.22.57.21 Version 2.4.6-stable+timestamp.2013.04.19.23.45.56
@@ -39,6 +39,7 @@ def user():
return dict(form=auth()) return dict(form=auth())
@cache.action()
def download(): def download():
""" """
allows downloading of uploaded files allows downloading of uploaded files
+1 -1
View File
@@ -437,7 +437,7 @@ class Cache(object):
# been accounted for # been accounted for
logger.warning('no cache.disk (AttributeError)') logger.warning('no cache.disk (AttributeError)')
def client(self, time_expire=DEFAULT_TIME_EXPIRE, cache_model=None, def action(self, time_expire=DEFAULT_TIME_EXPIRE, cache_model=None,
prefix=None, session=False, vars=True, lang=True, prefix=None, session=False, vars=True, lang=True,
user_agent=False, public=True, valid_statuses=None, user_agent=False, public=True, valid_statuses=None,
quick=None): quick=None):
+10 -6
View File
@@ -412,16 +412,20 @@ class Mail(object):
if (not text is None or not html is None) and (not raw): if (not text is None or not html is None) and (not raw):
attachment = MIMEMultipart.MIMEMultipart('alternative') attachment = MIMEMultipart.MIMEMultipart('alternative')
if not text is None: if not text is None:
if isinstance(text, basestring): if not isinstance(text, basestring):
text = text.read()
if isinstance(text, unicode):
text = text.encode('utf-8')
elif not encoding=='utf-8':
text = text.decode(encoding).encode('utf-8') text = text.decode(encoding).encode('utf-8')
else:
text = text.read().decode(encoding).encode('utf-8')
attachment.attach(MIMEText.MIMEText(text, _charset='utf-8')) attachment.attach(MIMEText.MIMEText(text, _charset='utf-8'))
if not html is None: if not html is None:
if isinstance(html, basestring): if not isinstance(html, basestring):
html = html.read()
if isinstance(html, unicode):
html = html.encode('utf-8')
elif not encoding=='utf-8':
html = html.decode(encoding).encode('utf-8') html = html.decode(encoding).encode('utf-8')
else:
html = html.read().decode(encoding).encode('utf-8')
attachment.attach( attachment.attach(
MIMEText.MIMEText(html, 'html', _charset='utf-8')) MIMEText.MIMEText(html, 'html', _charset='utf-8'))
payload_in.attach(attachment) payload_in.attach(attachment)