google.cloud.forseti.common.util.email.base_email_connector module

Base email connector to select connector

class BaseEmailConnector[source]

Bases: object

Base email connector.

_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 208
_abc_registry = <_weakrefset.WeakSet object>
_execute_send(email)[source]

Executes the sending of the email.

This needs to be a standalone method so that we can wrap it with retry, and the final exception can be gracefully handled upstream.

Parameters:email (mail) – Connector mail object
Returns:urllib2 response
Return type:dict
classmethod render_from_template(template_file, template_vars)[source]

Fill out an email template with template variables.

Parameters:
  • template_file (str) – The location of email template in filesystem.
  • template_vars (dict) – The template variables to fill into the template.
Returns:

The template content, rendered with the provided variables.

Return type:

str

send(email_sender=None, email_recipient=None, email_subject=None, email_content=None, content_type=None, attachment=None)[source]

Send an email.

This uses specific connector authentication details.

The minimum required info to send email are: sender, recipient, subject, and content (the body)

Parameters:
  • email_sender (str) – The email sender.
  • email_recipient (str) – The email recipient.
  • email_subject (str) – The email subject.
  • email_content (str) – The email content (aka, body).
  • content_type (str) – The email content type.
  • attachment (Attachment) – An Email Connector Attachment.
Raises:

EmailSendError – An error with sending email has occurred.