diff --git a/django/core/mail.py b/django/core/mail.py
index a5af6e6..7b09e47 100644
a
|
b
|
|
1 | 1 | # Use this module for e-mailing. |
2 | 2 | |
3 | 3 | from django.conf import settings |
4 | | from email.MIMEText import MIMEText |
| 4 | from email.MIMENonMultipart import MIMENonMultipart |
5 | 5 | from email.Header import Header |
6 | 6 | import smtplib, rfc822 |
7 | 7 | import socket |
… |
… |
DNS_NAME = socket.getfqdn() # Cache the hostname
|
13 | 13 | class BadHeaderError(ValueError): |
14 | 14 | pass |
15 | 15 | |
16 | | class SafeMIMEText(MIMEText): |
| 16 | class SafeMIMEText(MIMENonMultipart): |
| 17 | """Class for generating non-quoted text/* type MIME documents.""" |
| 18 | |
| 19 | def __init__(self, _text, _subtype='plain', _charset='us-ascii'): |
| 20 | """Create a text/* type MIME document. |
| 21 | |
| 22 | _text is the string for this message object. |
| 23 | |
| 24 | _subtype is the MIME sub content type, defaulting to "plain". |
| 25 | |
| 26 | _charset is the character set parameter added to the Content-Type |
| 27 | header. This defaults to "us-ascii". Note that as a side-effect, the |
| 28 | Content-Transfer-Encoding header will also be set. |
| 29 | """ |
| 30 | MIMENonMultipart.__init__(self, 'text', _subtype, |
| 31 | **{'charset': _charset}) |
| 32 | self.add_header('Content-Transfer-Encoding', 'quoted-printable') |
| 33 | self.set_payload(_text, _charset) |
| 34 | |
17 | 35 | def __setitem__(self, name, val): |
18 | 36 | "Forbids multi-line headers, to prevent header injection." |
19 | 37 | if '\n' in val or '\r' in val: |
20 | 38 | raise BadHeaderError, "Header values can't contain newlines (got %r for header %r)" % (val, name) |
21 | 39 | if name == "Subject": |
22 | 40 | val = Header(val, settings.DEFAULT_CHARSET) |
23 | | MIMEText.__setitem__(self, name, val) |
| 41 | MIMENonMultipart.__setitem__(self, name, val) |
24 | 42 | |
25 | 43 | def send_mail(subject, message, from_email, recipient_list, fail_silently=False, auth_user=settings.EMAIL_HOST_USER, auth_password=settings.EMAIL_HOST_PASSWORD): |
26 | 44 | """ |