code: def validate(self):
          
  
          if not (self.recipients or self.cc or self.bcc):
              raise InvalidMessage("No recipients have been added")
  
          if not self.body and not self.html:
              raise InvalidMessage("No body has been set")
  
          if not self.sender:
              raise InvalidMessage("No sender address has been set")
  
          if self.is_bad_headers():
              raise BadHeaders
docs: Checks if message is valid and raises appropriate exception.