1 min read

Python 3 SDK added to Paubox Email API

Highway stretching toward snow-capped mountains under blue sky

This month we released SDK support for Python 3 for Paubox Email API. It should be noted we created a new project repo for Python 3. Our Python 2 SDK is still available. As a recap, Paubox Email API allows developers to programmatically send HIPAA compliant email and track delivery status. Paubox Email API is HITRUST CSF certified. By adding client library support for languages like Python, programmers can integrate and deliver secure email within minutes via our REST API. Let's dive into a quick example.

 

Installation

 

Getting Paubox Email API Credentials

 

You will need to have a Paubox account. You can  sign up for free here. Once you have an account, follow the instructions on the Paubox Email API dashboard to verify domain ownership and generate API credentials.

See Also: Paubox Email API Quickstart Guide

 

Configuring API Credentials

 

Include your API credentials in a config file (e.g. config.cfg)
PAUBOX_HOST: 'https://api.paubox.net/v1/YOUR_ENDPOINT_NAME'
PAUBOX_API_KEY: 'YOUR_API_KEY'
Next install config package using pip to load API credentials from config.cfg file:
$ pip3 install config

Install Package

$ pip3 install paubox-python3

Usage

 

Sending Messages with the Paubox Mail Helper

 

Sending via Paubox is easy. This is the minimum content needed to send an email.
import paubox
from paubox.helpers.mail import Mail

from config import Config 
with open("config.cfg") as config_file:
    paubox_config = Config(config_file)

paubox_client = paubox.PauboxApiClient(paubox_config.PAUBOX_API_KEY, paubox_config.PAUBOX_HOST)
recipients = ["recipient@example.com"]
from_ = "sender@yourdomain.com"
subject = "Testing!"
content = {"text/plain": "Hello World!"}
mail = Mail(from_, subject, recipients, content)
response = paubox_client.send(mail.get())
print(response.status_code)
print(response.headers)
print(response.text)

Sending Messages without the Mail Helper Class

import paubox

from config import Config 
with open("config.cfg") as config_file:
    paubox_config = Config(config_file)

paubox_client = paubox.PauboxApiClient(paubox_config.PAUBOX_API_KEY, paubox_config.PAUBOX_HOST)
mail = {
    "data": {
        "message": {
            "recipients": [
                "recipient@example.com"
            ],
            "headers": {
                "subject": "Testing!",
                "from": "sender@yourdomain.com"
            },
            "content": {
                "text/plain": "Hello World!",
            }
        }
    }
}
response = paubox_client.send(mail)
print(response.status_code)
print(response.headers)
print(response.text)
Try the Paubox Email API for Free
Paubox customers at a company social event in a modern office with brick walls and hanging lights

Send HIPAA compliant transactional email with Python

Python Library for Paubox Email API The Paubox Python wrapper allows you to construct and send secure, HIPAA compliant messages. This package is the...

Read More
Paubox customers at a business meeting with laptops

Send HIPAA compliant transactional email with Ruby

Ruby for Paubox Email API The Paubox Ruby gem allows you to construct and send secure, HIPAA compliant transactional email. This package is the...

Read More
Person using laptop at desk in office

Send HIPAA compliant transactional email with Ruby on Rails

Ruby on Rails Gem for Paubox Email API The Paubox Ruby on Rails Gem can be used ActionMailer in Ruby on Rails. This Gem is the official Ruby on...

Read More

Subscribe to Paubox Weekly

Every Friday we bring you the most important news from Paubox. Our aim is to make you smarter, faster.