diff --git a/django/core/mail/__init__.py b/django/core/mail/__init__.py
index d17058b0d4..96840e24db 100644
a
|
b
|
def send_mail(subject, message, from_email, recipient_list,
|
63 | 63 | def send_mass_mail(datatuple, fail_silently=False, auth_user=None, |
64 | 64 | auth_password=None, connection=None): |
65 | 65 | """ |
66 | | Given a datatuple of (subject, message, from_email, recipient_list), send |
67 | | each message to each recipient list. Return the number of emails sent. |
| 66 | Given a datatuple of (subject, message, from_email, recipient_list, opts), |
| 67 | send each message to each recipient list. Return the number of emails sent. |
68 | 68 | |
69 | 69 | If from_email is None, use the DEFAULT_FROM_EMAIL setting. |
70 | 70 | If auth_user and auth_password are set, use them to log in. |
71 | 71 | If auth_user is None, use the EMAIL_HOST_USER setting. |
72 | 72 | If auth_password is None, use the EMAIL_HOST_PASSWORD setting. |
73 | 73 | |
| 74 | opts is a dictionary of the following optional arguments: |
| 75 | - html_message |
| 76 | |
74 | 77 | Note: The API for this method is frozen. New code wanting to extend the |
75 | 78 | functionality should use the EmailMessage class directly. |
76 | 79 | """ |
… |
… |
def send_mass_mail(datatuple, fail_silently=False, auth_user=None,
|
79 | 82 | password=auth_password, |
80 | 83 | fail_silently=fail_silently, |
81 | 84 | ) |
82 | | messages = [ |
83 | | EmailMessage(subject, message, sender, recipient, connection=connection) |
84 | | for subject, message, sender, recipient in datatuple |
85 | | ] |
| 85 | |
| 86 | messages = [] |
| 87 | for subject, message, sender, recipient, opts in datatuple: |
| 88 | html_message = opts.get('html_message') |
| 89 | message = EmailMessage( |
| 90 | subject, message, sender, recipient, |
| 91 | connection=connection, |
| 92 | html_message=html_message |
| 93 | ) |
| 94 | messages.append(message) |
| 95 | |
86 | 96 | return connection.send_messages(messages) |
87 | 97 | |
88 | 98 | |
diff --git a/django/core/mail/message.py b/django/core/mail/message.py
index e2bd712f56..b66f33549c 100644
a
|
b
|
class EmailMessage:
|
185 | 185 | |
186 | 186 | def __init__(self, subject='', body='', from_email=None, to=None, bcc=None, |
187 | 187 | connection=None, attachments=None, headers=None, cc=None, |
188 | | reply_to=None): |
| 188 | reply_to=None, html_message=None): |
189 | 189 | """ |
190 | 190 | Initialize a single email message (which can be sent to multiple |
191 | 191 | recipients). |
… |
… |
class EmailMessage:
|
227 | 227 | self.extra_headers = headers or {} |
228 | 228 | self.connection = connection |
229 | 229 | |
| 230 | if html_message: |
| 231 | self.attach_alternative(html_message, 'text/html') |
| 232 | |
230 | 233 | def get_connection(self, fail_silently=False): |
231 | 234 | from django.core.mail import get_connection |
232 | 235 | if not self.connection: |