Email Library

These functions provide access to email services. The sending rate is limited to 20 per hour. Delivery will not be guaranteed for any sends beyond this rate. If you have your own Mandrill account, you can use the Mandrill Library instead and you won't have the limitation of 20 per hour.

 

Import


To use this library and its functions, you must use the import line at the beginning of your Base Python code.

import Email

 

Classes

 

Email.Email

Usage: Email.Email(sender=None, display_name='', recipients=None, subject='', message='', attachments=None)

The Email class represents an email object.

  • Credit cost: 0
  • Parameters:
    • senderstr email address of the sender (FROM attribute). Must be 'no-reply@mediumone.com'.
    • display_namestr name of the sender to be displayed by the mail client
    • recipientsstr or [str] the recipient's email address. It also supports multiple email addresses separated by a semi-colon ';' or an array of strings.
    • subjectstr the email subject line
    • message (optional): str message (will default to text email if set.
    • attachments (optional): Email.EmailAttachment object
  • Returns:
    • Email.Email



Email.EmailAttachment

Usage: Email.EmailAttachment(datacontent_typename)

The EmailAttachment class represents an email attachment object.

  • Credit cost: 0
  • Parameters:
    • datastr base64 encoded string of the data to attach
    • content_typestr MIME Content-Type of the data being attached (for example 'image/jpeg;')
    • namestr a name to associate to the attachment
  • Returns:
    • Email.EmailAttachment



Functions

 

Email.Email.text_message

Usage: Email.Email.text_message(message)

Set the email message content to send as text. This overrides any message set during Email object creation.

  • Credit cost: 0
  • Parameters:
    • messagestr the message string.
      import Email
      email = Email.Email('no-reply@mediumone.com','my name','you@mail.com','message subject')
      email.text_message('from me to you... in text')
      email.send()
  • Returns: None



Email.Email.html_message

Usage: Email.Email.html_message(message)

Set the email message content to send as HTML. This overrides any message set during Email object creation.

  • Credit cost: 0
  • Parameters:
    • messagestr the HTML formatted message string.
      import Email
      email = Email.Email('no-reply@mediumone.com','my name','you@mail.com','message subject')
      email.html_message('<!DOCTYPE html><html><title>Title</title><head></head><body><h2>From me to you,</h2><p> in HTML</p></body></html>')
      email.send()
  • Returns: None



Email.Email.sender

Usage: Email.Email.sender(sender)

Set the email of the sender. This overrides any sender's email set during Email object creation.

  • Credit cost: 0
  • Parameters:
    • senderstr the sender's email address.
      import Email
      email = Email.Email('no-reply@mediumone.com','my name','you@mail.com','message subject')
      email.sender('me2@mail.com')
      email.html_message('<!DOCTYPE html><html><title>Title</title><head></head><body><h2>From me to you,</h2><p> in HTML</p></body></html>')
      email.send()
  • Returns: None
Email.Email.display_name

Usage: Email.Email.display_name(display_name)

Set the email of the sender. This overrides any sender's email set during Email object creation.

  • Credit cost: 0
  • Parameters:
    • display_namestr the sender's display name.
      import Email
      email = Email.Email('no-reply@mediumone.com,'my name','you@mail.com','message subject')
      email.display_name('my name too')
      email.html_message('<!DOCTYPE html><html><title>Title</title><head></head><body><h2>From me to you,</h2><p> in HTML</p></body></html>')
      email.send()
  • Returns: None



Email.Email.add_recipient

Usage: Email.Email.add_recipient(recipient)

Add a recipient's email to the list of recipients. This adds to the recipient's email list set during Email object creation.

  • Credit cost: 0
  • Parameters:
    • recipientstr a recipient's email address.
      import Email
      email = Email.Email('no-reply@mediumone.com','my name','you@mail.com','message subject')
      email.add_recipient('you2@mail.com')
      email.html_message('<!DOCTYPE html><html><title>Title</title><head></head><body><h2>From me to you,</h2><p> in HTML</p></body></html>')
      email.send()
  • Returns: None



Email.Email.add_attachment

Usage: Email.Email.add_attachment(attachment)

Add an attachment to the email. This adds to the attachment list.

  • Credit cost: 0
  • Parameters:
    • attachmentEmailAttachment object.
      import Email
      email = Email.Email('no-reply@mediumone.com','my name','you@mail.com','message subject')
      attachment = Email.EmailAttachment('iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==', 'image/png;', 'image of a red dot')
      email.html_message('<!DOCTYPE html><html><title>Title</title><head></head><body><h2>From me to you,</h2><p> in HTML</p></body></html>')
      email.add_attachment(attachment)
      email.send()
  • Returns: None




Email.Email.send

Usage: Email.Email.send()

Send the email message.

  • Credit cost: 1
  • Parameters: None
  • Returns: None