#7722: EMail Message with CC - Carbon Copy
------------------------------------------------------+---------------------
   Reporter:  roberto.digirolamo <[EMAIL PROTECTED]>  |                Owner:  
nobody    
     Status:  new                                     |            Milestone:   
         
  Component:  django.core.mail                        |              Version:  
SVN       
   Keywords:                                          |                Stage:  
Unreviewed
  Has_patch:  1                                       |           Needs_docs:  
0         
Needs_tests:  0                                       |   Needs_better_patch:  
1         
------------------------------------------------------+---------------------
 I modified class EmailMessage for use Carbon copy.

 {{{
     def __init__(self, subject='', body='', from_email=None, to=None,
 cc=None, bcc=None,
             connection=None, attachments=None, headers=None):
         """
         Initialize a single email message (which can be sent to multiple
         recipients).

         All strings used to create the message can be unicode strings (or
 UTF-8
         bytestrings). The SafeMIMEText class will handle any necessary
 encoding
         conversions.
         """
         if to:
             self.to = list(to)
         else:
             self.to = []
         if cc:
                         self.cc = list(cc)
                 else:
                         self.cc = []
         if bcc:
             self.bcc = list(bcc)
         else:
             self.bcc = []
         self.from_email = from_email or settings.DEFAULT_FROM_EMAIL
         self.subject = subject
         self.body = body
         self.attachments = attachments or []
         self.extra_headers = headers or {}
         self.connection = connection

         def message(self):
                 encoding = self.encoding or settings.DEFAULT_CHARSET
                 msg = SafeMIMEText(smart_str(self.body,
 settings.DEFAULT_CHARSET), self.content_subtype, encoding)
                 if self.attachments:
                         body_msg = msg
                         msg =
 SafeMIMEMultipart(_subtype=self.multipart_subtype)
                         if self.body:
                                 msg.attach(body_msg)
                         for attachment in self.attachments:
                                 if isinstance(attachment, MIMEBase):
                                         msg.attach(attachment)
                                 else:
 msg.attach(self._create_attachment(*attachment))
                 msg['Subject'] = self.subject
                 msg['From'] = self.from_email
                 msg['To'] = ', '.join(self.to)
                 if not self.cc == None:
                         msg['Cc'] = ', '.join(self.cc)
                 msg['Date'] = formatdate()
                 msg['Message-ID'] = make_msgid()
                 for name, value in self.extra_headers.items():
                         msg[name] = value
                 return msg

         def recipients(self):
                 """
                 Returns a list of all recipients of the email (includes
 direct
                 addressees as well as Bcc and Cc entries).
                 """
                 return self.to + self.cc + self.bcc
 }}}


 Best regards,
 Roberto

-- 
Ticket URL: <http://code.djangoproject.com/ticket/7722>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to