Ticket #1235: django-mail-charset-support.diff

File django-mail-charset-support.diff, 1.2 KB (added by igor@…, 9 years ago)

patch for support different charsets in mail messages

  • django/core/mail.py

     
    11# Use this module for e-mailing.
    22
    33from django.conf.settings import DEFAULT_FROM_EMAIL, EMAIL_HOST, EMAIL_SUBJECT_PREFIX
     4from django.conf.settings import DEFAULT_CHARSET
    45from email.MIMEText import MIMEText
    56import smtplib
    67
     
    1213        "Forbids multi-line headers, to prevent header injection."
    1314        if '\n' in val or '\r' in val:
    1415            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)
    1518        MIMEText.__setitem__(self, name, val)
    1619
    1720def send_mail(subject, message, from_email, recipient_list, fail_silently=False):
     
    3942        if not recipient_list:
    4043            continue
    4144        from_email = from_email or DEFAULT_FROM_EMAIL
    42         msg = SafeMIMEText(message)
     45        msg = SafeMIMEText(message, 'plain', DEFAULT_CHARSET)
    4346        msg['Subject'] = subject
    4447        msg['From'] = from_email
    4548        msg['To'] = ', '.join(recipient_list)
Back to Top