Index: django_trunk/django/core/mail.py
===================================================================
--- django_trunk.orig/django/core/mail.py	2008-07-16 08:45:07.773038321 +0900
+++ django_trunk/django/core/mail.py	2008-07-16 08:56:40.178035252 +0900
@@ -69,7 +69,7 @@
 class BadHeaderError(ValueError):
     pass
 
-def forbid_multi_line_headers(name, val):
+def forbid_multi_line_headers(name, val, header_encoding):
     """Forbids multi-line headers, to prevent header injection."""
     if '\n' in val or '\r' in val:
         raise BadHeaderError("Header values can't contain newlines (got %r for header %r)" % (val, name))
@@ -80,21 +80,27 @@
             result = []
             for item in val.split(', '):
                 nm, addr = parseaddr(item)
-                nm = str(Header(nm, settings.DEFAULT_CHARSET))
+                nm = str(Header(nm, header_encoding))
                 result.append(formataddr((nm, str(addr))))
             val = ', '.join(result)
         else:
-            val = Header(force_unicode(val), settings.DEFAULT_CHARSET)
+            val = Header(force_unicode(val), header_encoding)
     return name, val
 
 class SafeMIMEText(MIMEText):
+    def __init__(self, text, subtype, charset, header_encoding=None):
+        self.header_encoding = header_encoding or settings.DEFAULT_CHARSET
+        MIMEText.__init__(self, text, subtype, charset)
     def __setitem__(self, name, val):
-        name, val = forbid_multi_line_headers(name, val)
+        name, val = forbid_multi_line_headers(name, val, self.header_encoding)
         MIMEText.__setitem__(self, name, val)
 
 class SafeMIMEMultipart(MIMEMultipart):
+    def __init__(self, _subtype='mixed', boundary=None, _subparts=None, header_encoding=None, **_params):
+        self.header_encoding = header_encoding or settings.DEFAULT_CHARSET
+        MIMEMultipart.__init__(self, _subtype, boundary, _subparts, **_params)
     def __setitem__(self, name, val):
-        name, val = forbid_multi_line_headers(name, val)
+        name, val = forbid_multi_line_headers(name, val, self.header_encoding)
         MIMEMultipart.__setitem__(self, name, val)
 
 class SMTPConnection(object):
@@ -195,7 +201,7 @@
     encoding = None     # None => use settings default
 
     def __init__(self, subject='', body='', from_email=None, to=None, bcc=None,
-            connection=None, attachments=None, headers=None):
+            connection=None, attachments=None, headers=None, header_encoding=None):
         """
         Initialize a single email message (which can be sent to multiple
         recipients).
@@ -220,6 +226,7 @@
         self.attachments = attachments or []
         self.extra_headers = headers or {}
         self.connection = connection
+        self.header_encoding = header_encoding
 
     def get_connection(self, fail_silently=False):
         if not self.connection:
@@ -228,11 +235,12 @@
 
     def message(self):
         encoding = self.encoding or settings.DEFAULT_CHARSET
+        header_encoding = self.header_encoding or settings.DEFAULT_CHARSET
         msg = SafeMIMEText(smart_str(self.body, settings.DEFAULT_CHARSET),
-                           self.content_subtype, encoding)
+                           self.content_subtype, encoding, header_encoding)
         if self.attachments:
             body_msg = msg
-            msg = SafeMIMEMultipart(_subtype=self.multipart_subtype)
+            msg = SafeMIMEMultipart(_subtype=self.multipart_subtype, header_encoding=header_encoding)
             if self.body:
                 msg.attach(body_msg)
             for attachment in self.attachments:
@@ -318,13 +326,15 @@
         self.attach(content=content, mimetype=mimetype)
 
 def send_mail(subject, message, from_email, recipient_list,
-              fail_silently=False, auth_user=None, auth_password=None):
+              fail_silently=False, auth_user=None, auth_password=None,
+              header_encoding=None):
     """
     Easy wrapper for sending a single message to a recipient list. All members
     of the recipient list will see the other recipients in the 'To' field.
 
     If auth_user is None, the EMAIL_HOST_USER setting is used.
     If auth_password is None, the EMAIL_HOST_PASSWORD setting is used.
+    If header_encoding is None, the DEFAULT_CHARSET setting is used.
 
     Note: The API for this method is frozen. New code wanting to extend the
     functionality should use the EmailMessage class directly.
@@ -332,10 +342,10 @@
     connection = SMTPConnection(username=auth_user, password=auth_password,
                                 fail_silently=fail_silently)
     return EmailMessage(subject, message, from_email, recipient_list,
-                        connection=connection).send()
+                        connection=connection, header_encoding=header_encoding).send()
 
 def send_mass_mail(datatuple, fail_silently=False, auth_user=None,
-                   auth_password=None):
+                   auth_password=None, header_encoding=None):
     """
     Given a datatuple of (subject, message, from_email, recipient_list), sends
     each message to each recipient list. Returns the number of e-mails sent.
@@ -344,13 +354,14 @@
     If auth_user and auth_password are set, they're used to log in.
     If auth_user is None, the EMAIL_HOST_USER setting is used.
     If auth_password is None, the EMAIL_HOST_PASSWORD setting is used.
+    If header_encoding is None, the DEFAULT_CHARSET setting is used.
 
     Note: The API for this method is frozen. New code wanting to extend the
     functionality should use the EmailMessage class directly.
     """
     connection = SMTPConnection(username=auth_user, password=auth_password,
                                 fail_silently=fail_silently)
-    messages = [EmailMessage(subject, message, sender, recipient)
+    messages = [EmailMessage(subject, message, sender, recipient, header_encoding=header_encoding)
                 for subject, message, sender, recipient in datatuple]
     return connection.send_messages(messages)
 
Index: django_trunk/docs/email.txt
===================================================================
--- django_trunk.orig/docs/email.txt	2008-07-16 08:45:07.801041528 +0900
+++ django_trunk/docs/email.txt	2008-07-16 10:36:19.965034474 +0900
@@ -245,11 +245,15 @@
       caller to ensure header names and values are in the correct format for
       an e-mail message.
 
+    * ``header_encoding``: The encoding of the email header. Defaults to DEFAULT_CHARSET
+      setting.
+
 For example::
 
     email = EmailMessage('Hello', 'Body goes here', 'from@example.com',
                 ['to1@example.com', 'to2@example.com'], ['bcc@example.com'],
-                headers = {'Reply-To': 'another@example.com'})
+                headers = {'Reply-To': 'another@example.com'},
+                header_encoding = 'utf-8')
 
 The class has the following methods:
 
