Ticket #1235: django-mail-charset-support.2.diff
File django-mail-charset-support.2.diff, 1.1 KB (added by , 19 years ago) |
---|
-
django/core/mail.py
2 2 3 3 from django.conf import settings 4 4 from email.MIMEText import MIMEText 5 from email.Header import Header 5 6 import smtplib 6 7 7 8 class BadHeaderError(ValueError): … … 12 13 "Forbids multi-line headers, to prevent header injection." 13 14 if '\n' in val or '\r' in val: 14 15 raise BadHeaderError, "Header values can't contain newlines (got %r for header %r)" % (val, name) 16 if name == 'Subject': 17 val = Header(val, settings.DEFAULT_CHARSET) 15 18 MIMEText.__setitem__(self, name, val) 16 19 17 20 def send_mail(subject, message, from_email, recipient_list, fail_silently=False): … … 39 42 if not recipient_list: 40 43 continue 41 44 from_email = from_email or settings.DEFAULT_FROM_EMAIL 42 msg = SafeMIMEText(message )45 msg = SafeMIMEText(message, 'plain', settings.DEFAULT_CHARSET) 43 46 msg['Subject'] = subject 44 47 msg['From'] = from_email 45 48 msg['To'] = ', '.join(recipient_list)