Email utility module.
SendgridConnector
(sender, recipient, kwargs)[source]¶Bases: google.cloud.forseti.common.util.email.base_email_connector.BaseEmailConnector
Utility for sending emails using Sendgrid API Key.
_abc_cache
= <_weakrefset.WeakSet object>¶_abc_negative_cache
= <_weakrefset.WeakSet object>¶_abc_negative_cache_version
= 208¶_abc_registry
= <_weakrefset.WeakSet object>¶_add_recipients
(email, email_recipients)[source]¶Add multiple recipients to the sendgrid email object.
Parameters: |
|
---|---|
Returns: | SendGrid mail object with multiple recipients. |
Return type: | SendGrid |
_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 (SendGrid) – SendGrid mail object |
---|---|
Returns: | urllib2 response object |
Return type: | dict |
create_attachment
(file_location, content_type, filename, disposition='attachment', content_id=None)[source]¶Create a SendGrid attachment.
SendGrid attachments file content must be base64 encoded.
Parameters: |
|
---|---|
Returns: | A SendGrid Attachment. |
Return type: | Attachment |
send
(email_sender=None, email_recipient=None, email_subject=None, email_content=None, content_type=None, attachment=None)[source]¶Send an email.
This uses the SendGrid API. https://github.com/sendgrid/sendgrid-python
The minimum required info to send email are: sender, recipient, subject, and content (the body)
Parameters: |
|
---|---|
Raises: |
|