Fixed #2007 -- Added support for configurable encoding of email message bodies.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@5553 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2007-06-27 12:54:15 +00:00
parent 26659f2782
commit eeb4ffc2c1
1 changed files with 3 additions and 1 deletions

View File

@ -171,6 +171,7 @@ class EmailMessage(object):
"""
content_subtype = 'plain'
multipart_subtype = 'mixed'
encoding = None # None => use settings default
def __init__(self, subject='', body='', from_email=None, to=None, bcc=None,
connection=None, attachments=None, headers=None):
@ -189,7 +190,8 @@ class EmailMessage(object):
return self.connection
def message(self):
msg = SafeMIMEText(self.body, self.content_subtype, settings.DEFAULT_CHARSET)
encoding = self.encoding or settings.DEFAULT_CHARSET
msg = SafeMIMEText(self.body, self.content_subtype, encoding)
if self.attachments:
body_msg = msg
msg = SafeMIMEMultipart(_subtype=self.multipart_subtype)