Mailjet email connector module.

class Attachment(filename, content_type, content, disposition='attachment')[source]

Bases: object

Mailjet attachment.


Returns mailjet_rest API attachment payload.

Returns:mailjet_rest API attachment payload
Return type:dict
class MailjetConnector(sender, recipient, auth, custom=None)[source]


Utility for sending emails using Mailjet API Key.

_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 208
_abc_registry = <_weakrefset.WeakSet object>
_execute_send(email) → requests.models.Response[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 (dict) – Mailjet mail object
Returns:urllib2 response object
Return type:dict
classmethod create_attachment(file_location=None, content_type=None, filename=None, disposition='attachment', content_id=None)[source]

Create a Mailjet attachment.

Mailjet attachments file content must be base64 encoded.

  • file_location (str) – The path of the file.
  • content_type (str) – The content type of the attachment.
  • filename (str) – The filename of attachment.
  • disposition (str) – Content disposition, defaults to “attachment”.
  • content_id (str) – The content id.

A Mailjet Attachment.

Return type:


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.

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

  • email_sender (str) – The email sender.
  • email_recipient (str) – The email recipient.
  • email_subject (str) – The email subject.
  • email_content (str) – The email HTML content (aka, body).
  • content_type (str) – The email content type.
  • attachment (Attachment) – A Mailjet Attachment.

EmailSendError – An error with sending email has occurred.