Ticket #1235: django-mail-charset-support.diff
File django-mail-charset-support.diff, 1.2 KB (added by , 19 years ago) |
---|
-
django/core/mail.py
1 1 # Use this module for e-mailing. 2 2 3 3 from django.conf.settings import DEFAULT_FROM_EMAIL, EMAIL_HOST, EMAIL_SUBJECT_PREFIX 4 from django.conf.settings import DEFAULT_CHARSET 4 5 from email.MIMEText import MIMEText 5 6 import smtplib 6 7 … … 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, 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 DEFAULT_FROM_EMAIL 42 msg = SafeMIMEText(message )45 msg = SafeMIMEText(message, 'plain', DEFAULT_CHARSET) 43 46 msg['Subject'] = subject 44 47 msg['From'] = from_email 45 48 msg['To'] = ', '.join(recipient_list)