Ticket #5790: django-core-mail-add-cc-support

File django-core-mail-add-cc-support, 1.5 KB (added by tpetazzoni, 17 years ago)

Patch that adds support for Cc

Line 
1Index: django/core/mail.py
2===================================================================
3--- django/core/mail.py (révision 6576)
4+++ django/core/mail.py (copie de travail)
5@@ -199,7 +199,7 @@
6 multipart_subtype = 'mixed'
7 encoding = None # None => use settings default
8
9- def __init__(self, subject='', body='', from_email=None, to=None, bcc=None,
10+ def __init__(self, subject='', body='', from_email=None, to=None, cc=None, bcc=None,
11 connection=None, attachments=None, headers=None):
12 """
13 Initialise a single email message (which can be sent to multiple
14@@ -210,6 +210,7 @@
15 conversions.
16 """
17 self.to = to or []
18+ self.cc = cc or []
19 self.bcc = bcc or []
20 self.from_email = from_email or settings.DEFAULT_FROM_EMAIL
21 self.subject = subject
22@@ -241,6 +242,8 @@
23 msg['To'] = ', '.join(self.to)
24 msg['Date'] = formatdate()
25 msg['Message-ID'] = make_msgid()
26+ if self.cc:
27+ msg['Cc'] = ', '.join(self.cc)
28 if self.bcc:
29 msg['Bcc'] = ', '.join(self.bcc)
30 for name, value in self.extra_headers.items():
31@@ -252,7 +255,7 @@
32 Returns a list of all recipients of the email (includes direct
33 addressees as well as Bcc entries).
34 """
35- return self.to + self.bcc
36+ return self.to + self.cc + self.bcc
37
38 def send(self, fail_silently=False):
39 """Send the email message."""
Back to Top