def SendRetrievalEmail(self, entity, user):
    data = {
        'entity': entity,
        'helpdesk_email': settings.HELPDESK_EMAIL,
        'helpdesk_name': settings.HELPDESK_NAME,
        'retrieved_by': user.user.email(),
    }
    body = self.RenderTemplate('retrieval_email.txt', data, response_out=False)

    user_email = user.user.email()
    try:
      # If the user has access to "silently" retrieve keys without the owner
      # being notified, email only SILENT_AUDIT_ADDRESSES.
      self.VerifyPermissions(permissions.SILENT_RETRIEVE, user=user)
      to = [user_email] + settings.SILENT_AUDIT_ADDRESSES
    except models.AccessDeniedError:
      # Otherwise email the owner and RETRIEVE_AUDIT_ADDRESSES.
      to = [user_email] + settings.RETRIEVE_AUDIT_ADDRESSES
      if entity.owner:
        if '@' in entity.owner:
          owner_email = entity.owner
        else:
          owner_email = '%s@%s' % (entity.owner, settings.DEFAULT_EMAIL_DOMAIN)
        to.append(owner_email)

    subject_var = '%s_RETRIEVAL_EMAIL_SUBJECT' % entity.ESCROW_TYPE_NAME.upper()
    subject = getattr(
        settings, subject_var, 'Escrow secret retrieval notification.')
    util.SendEmail(to, subject, body)
Sends a retrieval notification email.
dataset/ETHPy150Open google/cauliflowervest/src/cauliflowervest/server/handlers/__init__.py/AccessHandler.SendRetrievalEmail