Ticket #7722: cc-r13609.diff
File cc-r13609.diff, 4.8 KB (added by , 14 years ago) |
---|
-
django/core/mail/message.py
105 105 encoding = None # None => use settings default 106 106 107 107 def __init__(self, subject='', body='', from_email=None, to=None, bcc=None, 108 connection=None, attachments=None, headers=None ):108 connection=None, attachments=None, headers=None, cc=None): 109 109 """ 110 110 Initialize a single email message (which can be sent to multiple 111 111 recipients). … … 119 119 self.to = list(to) 120 120 else: 121 121 self.to = [] 122 if cc: 123 assert not isinstance(cc, basestring), '"cc" argument must be a list or tuple' 124 self.cc = list(cc) 125 else: 126 self.cc = [] 122 127 if bcc: 123 128 assert not isinstance(bcc, basestring), '"bcc" argument must be a list or tuple' 124 129 self.bcc = list(bcc) … … 145 150 msg['Subject'] = self.subject 146 151 msg['From'] = self.extra_headers.get('From', self.from_email) 147 152 msg['To'] = ', '.join(self.to) 153 if self.cc: 154 msg['Cc'] = ', '.join(self.cc) 148 155 149 156 # Email header names are case-insensitive (RFC 2045), so we have to 150 157 # accommodate that when doing comparisons. … … 162 169 def recipients(self): 163 170 """ 164 171 Returns a list of all recipients of the email (includes direct 165 addressees as well as Bcc entries).172 addressees as well as Cc and Bcc entries). 166 173 """ 167 return self.to + self. bcc174 return self.to + self.cc + self.bcc 168 175 169 176 def send(self, fail_silently=False): 170 177 """Sends the email message.""" … … 252 259 alternative_subtype = 'alternative' 253 260 254 261 def __init__(self, subject='', body='', from_email=None, to=None, bcc=None, 255 connection=None, attachments=None, headers=None, alternatives=None): 262 connection=None, attachments=None, headers=None, alternatives=None, 263 cc=None): 256 264 """ 257 265 Initialize a single email message (which can be sent to multiple 258 266 recipients). … … 261 269 bytestrings). The SafeMIMEText class will handle any necessary encoding 262 270 conversions. 263 271 """ 264 super(EmailMultiAlternatives, self).__init__(subject, body, from_email, to, bcc, connection, attachments, headers )272 super(EmailMultiAlternatives, self).__init__(subject, body, from_email, to, bcc, connection, attachments, headers, cc) 265 273 self.alternatives=alternatives or [] 266 274 267 275 def attach_alternative(self, content, mimetype): -
tests/regressiontests/mail/tests.py
417 417 >>> settings.ADMINS = old_admins 418 418 >>> settings.MANAGERS = old_managers 419 419 420 # Add Cc to the email argument list (#7722) 421 422 >>> email = EmailMessage('Subject', 'Content', 'from@example.com', ['to@example.com'], cc=['cc@example.com']) 423 >>> message = email.message() 424 >>> message['Cc'] 425 'cc@example.com' 426 >>> email.recipients() 427 ['to@example.com', 'cc@example.com'] 428 429 >>> email = EmailMessage('Subject', 'Content', 'from@example.com', ['to@example.com','other@example.com'], cc=['cc@example.com', 'cc.other@example.com']) 430 >>> message = email.message() 431 >>> message['Cc'] 432 'cc@example.com, cc.other@example.com' 433 >>> email.recipients() 434 ['to@example.com', 'other@example.com', 'cc@example.com', 'cc.other@example.com'] 435 436 >>> email = EmailMessage('Subject', 'Content', 'from@example.com', ['to@example.com','other@example.com'], cc=['cc@example.com', 'cc.other@example.com'], bcc=['bcc@example.com']) 437 >>> message = email.message() 438 >>> email.recipients() 439 ['to@example.com', 'other@example.com', 'cc@example.com', 'cc.other@example.com', 'bcc@example.com'] 440 441 >>> email = EmailMessage('Subject', 'Content', 'from@example.com', ['to@example.com'], cc=['cc@example.com']) 442 >>> message = email.message() 443 >>> message.as_string() 444 'Content-Type: text/plain; charset="utf-8"\nMIME-Version: 1.0\nContent-Transfer-Encoding: quoted-printable\nSubject: Subject\nFrom: from@example.com\nTo: to@example.com\nCc: cc@example.com\nDate: ...\nMessage-ID: <...>\n\nContent' 445 420 446 """ -
docs/topics/email.txt
261 261 caller to ensure header names and values are in the correct format for 262 262 an e-mail message. 263 263 264 # ``cc``: A list or tuple of addresses used in the "Cc" receiver field when 265 sending the e-mail. 266 264 267 For example:: 265 268 266 269 email = EmailMessage('Hello', 'Body goes here', 'from@example.com',