Example #1
0
 def _resolve_addresses(self, to, cc, bcc, validate_email, throw_invalid_exception):
     """ Handle the targets addresses, adding aliases when defined """
     addresses = {'recipients': []}
     if to is not None:
         self._make_addr_alias_target(to, addresses, 'To')
     elif cc is not None and bcc is not None:
         self._make_addr_alias_target(
             [self.user, self.useralias], addresses, 'To')
     else:
         addresses['recipients'].append(self.user)
     if cc is not None:
         self._make_addr_alias_target(cc, addresses, 'Cc')
     if bcc is not None:
         self._make_addr_alias_target(bcc, addresses, 'Bcc')
     if validate_email:
         for email_addr in addresses['recipients']:
             try:
                 validate_email_with_regex(email_addr)
             except YagInvalidEmailAddress as err:
                 if throw_invalid_exception:
                     raise err
                 else:
                     self.log.error(err)
                     addresses['recipients'].remove(email_addr)
     return addresses
Example #2
0
 def _resolveAddresses(self, to, cc, bcc, validate_email,
                       throw_invalid_exception):
     """ Handle the targets addresses, adding aliases when defined """
     addresses = {'recipients': []}
     if to is not None:
         self._make_addr_alias_target(to, addresses, 'To')
     elif cc is not None and bcc is not None:
         self._make_addr_alias_target(
             [self.user, self.useralias], addresses, 'To')
     else:
         addresses['recipients'].append(self.user)
     if cc is not None:
         self._make_addr_alias_target(cc, addresses, 'Cc')
     if bcc is not None:
         self._make_addr_alias_target(bcc, addresses, 'Bcc')
     if validate_email:
         for email_addr in addresses['recipients']:
             try:
                 validate_email_with_regex(email_addr)
             except YagInvalidEmailAddress as e:
                 if throw_invalid_exception:
                     raise e
                 else:
                     self.log.error(e)
                     addresses['recipients'].remove(email_addr)
     return addresses