Hello.
I think it would be very useful if it was possible to send e-mail (using
'django.core.mail') in something different than 'us-ascii', for example,
in 'utf-8' by default. I have tried to implement this:
=
Index: django/conf/global_settings.py
===
--- django/conf/global_settings.py (revision 1983)
+++ django/conf/global_settings.py (working copy)
@@ -68,6 +68,9 @@
DEFAULT_CONTENT_TYPE = 'text/html'
DEFAULT_CHARSET = 'utf-8'
+# Default charset used for sending e-mail messages.
+DEFAULT_EMAIL_CHARSET = 'utf-8'
+
# E-mail address that error messages come from.
SERVER_EMAIL = '[EMAIL PROTECTED]'
Index: django/core/mail.py
===
--- django/core/mail.py (revision 1983)
+++ django/core/mail.py (working copy)
@@ -1,7 +1,9 @@
# Use this module for e-mailing.
from django.conf.settings import DEFAULT_FROM_EMAIL, EMAIL_HOST,
EMAIL_SUBJECT_PREFIX
+from django.conf.settings import DEFAULT_EMAIL_CHARSET
from email.MIMEText import MIMEText
+from email.Header import Header
import smtplib
class BadHeaderError(ValueError):
@@ -39,8 +41,8 @@
if not recipient_list:
continue
from_email = from_email or DEFAULT_FROM_EMAIL
-msg = SafeMIMEText(message)
-msg['Subject'] = subject
+msg = SafeMIMEText(message, 'plain', DEFAULT_EMAIL_CHARSET)
+msg['Subject'] = str(Header(subject,
DEFAULT_EMAIL_CHARSET)).replace('\n', '').replace('\r', '')
msg['From'] = from_email
msg['To'] = ', '.join(recipient_list)
server.sendmail(from_email, recipient_list, msg.as_string())
=
--
Igor Goryachev E-Mail/Jabber: [EMAIL PROTECTED]