Subclass EmailMultiAlternatives to add CC: option

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
from django.core.mail.message import EmailMultiAlternatives

class EmailMultiAlternativesCC(EmailMultiAlternatives):
    
    def __init__(self, *args, **kwargs):
        if kwargs.has_key('cc'):
            self.cc = kwargs['cc']
            del kwargs['cc']
        EmailMultiAlternatives.__init__(self, *args, **kwargs)
    
    def message(self):
        msg = EmailMultiAlternatives.message(self)
        if self.cc:
            msg['Cc'] = ', '.join(self.cc)
        return msg
    
    def recipients(self):
        l = EmailMultiAlternatives.recipients(self)
        if self.cc:
            return l + self.cc
        return l

More like this

  1. FixedEmailMessage by buriy 5 years, 3 months ago
  2. Execute a signal once by johnnoone 4 years, 1 month ago
  3. Soft Timeout Middleware by adamlofts 4 years ago
  4. simple email validation function by flavio87 4 years, 8 months ago
  5. MultiSelectField by steph 1 year, 3 months ago

Comments

(Forgotten your password?)